Browse Source

扫码出库功能基本实现

lwx_dev
erdanergou 3 years ago
parent
commit
836af94789
  1. 360
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 19
      src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java
  3. 126
      src/main/java/com/dreamchaser/depository_manage/controller/PageController.java
  4. 5
      src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecordMin.java
  5. 21
      src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java
  6. 75
      src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml
  7. 2
      src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml
  8. 8
      src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.java
  9. 7
      src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml
  10. 5
      src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationModel.java
  11. 75
      src/main/java/com/dreamchaser/depository_manage/pojo/SimpleApplicationOutMinRecordP.java
  12. 30
      src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java
  13. 9
      src/main/java/com/dreamchaser/depository_manage/service/PlaceService.java
  14. 1
      src/main/java/com/dreamchaser/depository_manage/service/UserService.java
  15. 459
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  16. 2
      src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java
  17. 14
      src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java
  18. 5
      src/main/java/com/dreamchaser/depository_manage/service/impl/UserServiceImpl.java
  19. 37
      src/main/resources/templates/pages/application/application-out.html
  20. 121
      src/main/resources/templates/pages/application/application-out_min.html
  21. 29
      src/main/resources/templates/pages/application/application-review.html
  22. 13
      src/main/resources/templates/pages/application/application_multi.html
  23. 28
      src/main/resources/templates/pages/application/form-step-look_back.html
  24. 128
      src/main/resources/templates/pages/application/my-task.html
  25. 5
      src/main/resources/templates/pages/depository/table-in.html
  26. 11
      src/main/resources/templates/pages/depository/table-out.html
  27. 2
      src/main/resources/templates/pages/depository/table-stock.html
  28. 9
      src/main/resources/templates/pages/material/material-out.html
  29. 1
      src/main/resources/templates/pages/material/selectType.html
  30. 1
      src/main/resources/templates/pages/place/place_edit.html
  31. 1
      src/main/resources/templates/pages/post/postRole_add.html
  32. 329
      src/main/resources/templates/pages/scanQrCode/scanQrCodeOut.html
  33. 10
      src/test/java/com/dreamchaser/depository_manage/Test.java
  34. 75
      target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml
  35. 2
      target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml
  36. 7
      target/classes/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml
  37. 37
      target/classes/templates/pages/application/application-out.html
  38. 121
      target/classes/templates/pages/application/application-out_min.html
  39. 29
      target/classes/templates/pages/application/application-review.html
  40. 13
      target/classes/templates/pages/application/application_multi.html
  41. 28
      target/classes/templates/pages/application/form-step-look_back.html
  42. 128
      target/classes/templates/pages/application/my-task.html
  43. 5
      target/classes/templates/pages/depository/table-in.html
  44. 11
      target/classes/templates/pages/depository/table-out.html
  45. 2
      target/classes/templates/pages/depository/table-stock.html
  46. 9
      target/classes/templates/pages/material/material-out.html
  47. 1
      target/classes/templates/pages/material/selectType.html
  48. 1
      target/classes/templates/pages/place/place_edit.html
  49. 1
      target/classes/templates/pages/post/postRole_add.html
  50. 150
      target/classes/templates/pages/scanQrCode/scanQrCode2.html
  51. 332
      target/classes/templates/pages/scanQrCode/scanQrCodeOut.html

360
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -7,10 +7,7 @@ import com.dreamchaser.depository_manage.entity.*;
import com.dreamchaser.depository_manage.exception.MyException;
import com.dreamchaser.depository_manage.pojo.*;
import com.dreamchaser.depository_manage.security.bean.UserToken;
import com.dreamchaser.depository_manage.service.CompanyService;
import com.dreamchaser.depository_manage.service.DepositoryRecordService;
import com.dreamchaser.depository_manage.service.DepositoryService;
import com.dreamchaser.depository_manage.service.MaterialService;
import com.dreamchaser.depository_manage.service.*;
import com.dreamchaser.depository_manage.utils.CrudUtil;
import com.dreamchaser.depository_manage.utils.DateUtil;
import com.dreamchaser.depository_manage.utils.HttpUtils;
@ -20,6 +17,7 @@ import org.apache.http.protocol.HTTP;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@ -45,6 +43,11 @@ public class DepositoryRecordController {
private CompanyService companyService;
@Autowired
private RedisTemplate<Object,Object> redisTemplate;
@Autowired
private RedisTemplate<String,String> redisTemplateForHash;
@Autowired
private PlaceService placeService;
@ -64,12 +67,16 @@ public class DepositoryRecordController {
List<ApplicationInRecordP> applicationInRecordPlist = depositoryRecordService.findApplicationInRecordPByCondition(map);
Integer InCount = depositoryRecordService.findApplicationInRecordPCountByCondition(map);
for (int i = 0; i < applicationInRecordPlist.size(); i++) {
applicationInRecordPlist.get(i).setPrice(applicationInRecordPlist.get(i).getPrice() / 100);
if(applicationInRecordPlist.get(i).getPrice() != null) {
applicationInRecordPlist.get(i).setPrice(applicationInRecordPlist.get(i).getPrice() / 100);
}
}
List<ApplicationOutRecordP> applicationOutRecordPlist = depositoryRecordService.findApplicationOutRecordPByCondition(map);
Integer OutCount = depositoryRecordService.findApplicationOutRecordPCountByCondition(map);
for (int i = 0; i < applicationOutRecordPlist.size(); i++) {
applicationOutRecordPlist.get(i).setPrice(applicationOutRecordPlist.get(i).getPrice() / 100);
if(applicationOutRecordPlist.get(i).getPrice() != null) {
applicationOutRecordPlist.get(i).setPrice(applicationOutRecordPlist.get(i).getPrice() / 100);
}
}
Map<String,Object> result = new HashMap<>();
result.put("applicationIn",applicationInRecordPlist);
@ -87,6 +94,77 @@ public class DepositoryRecordController {
return new RestResponse(myTask
,depositoryRecordService.findMyTaskOutCount(map),200);
}
// 查找当前用户所有的扫码出库订单
@GetMapping("/myTashForScanQrCode")
public RestResponse findAllMinRecordByUser(@RequestParam Map<String,Object> map,HttpServletRequest request){
List<SimpleApplicationOutMinRecordP> result = new ArrayList<>();
// isDone 为0为未完成,1为已完成
String isDone = (String) (map.get("isDone"));
UserByPort userToken= (UserByPort) request.getAttribute("userToken");
// 获取当前用户下的所有扫码出库订单
String key = "user:"+userToken.getId().toString();
String minRecord = (String) redisTemplateForHash.opsForHash().get(key, "minRecord");
if(minRecord == null){
return new RestResponse(result,result.size(),200);
}
// 获取子订单键值
String[] split = minRecord.replace("[","").replace("]","").split(",");
String completeSplit= "";// 已完成
String ongoingSplit= ""; // 进行中
for (int i = 0; i < split.length; i++) {
// 获取所有子订单状态
String state = (String) redisTemplateForHash.opsForHash().get(split[i],"state");
if("1".equals(state)){
// 如果当前订单未完成
ongoingSplit+= split[i]+",";
}else if ("2".equals(state)){
// 如果当前订单已完成
completeSplit+= split[i]+",";
}
}
// 用户管理仓库
Map<String,Object> userManageHouse = new HashMap<>();
if("1".equals(isDone)){
// 如果要获取已完成
split = completeSplit.split(",");
}else{
// 如果获取未完成
split = ongoingSplit.split(",");
}
for (int i = 0; i < split.length; i++) {
// 获取子订单编码
String[] strings = split[i].split(":");
String minRecordId = "";
if(strings.length>1) {
minRecordId = strings[1];
}
if("".equals(minRecordId)){
continue;
}
// 获取数据库中子订单信息
ApplicationOutRecordMin applicationOutMinById = depositoryRecordService.findApplicationOutMinById(ObjectFormatUtil.toInteger(minRecordId));
// 获取仓库信息
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(applicationOutMinById.getDepositoryId());
// 获取子订单对应主订单
ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(applicationOutMinById.getParentId());
// 创建展示对象
SimpleApplicationOutMinRecordP simpleApplicationOutMinRecordP = new SimpleApplicationOutMinRecordP(applicationOutMinById);
simpleApplicationOutMinRecordP.setApplicantTime(DateUtil.TimeStampToDateTime(Long.valueOf(applicationOutRecordPById.getApplicantTime())));
simpleApplicationOutMinRecordP.setApplyRemark(applicationOutRecordPById.getApplyRemark());
simpleApplicationOutMinRecordP.setDepositoryId(depositoryRecordById.getId());
simpleApplicationOutMinRecordP.setDepositoryName(depositoryRecordById.getDname());
simpleApplicationOutMinRecordP.setCode(applicationOutRecordPById.getCode());
List<Object> objectList = (List<Object>) userManageHouse.get(depositoryRecordById.getCode());
if(objectList == null){
objectList = new ArrayList<>();
}
objectList.add(simpleApplicationOutMinRecordP);
userManageHouse.put(depositoryRecordById.getCode(),objectList);
}
return new RestResponse(userManageHouse);
}
@PostMapping("/depositoryRecord")
public RestResponse insertDepositoryRecord(@RequestBody Map<String,Object> map, HttpServletRequest request){
UserByPort userToken= (UserByPort) request.getAttribute("userToken");
@ -210,7 +288,7 @@ public class DepositoryRecordController {
}else{
// 插入主订单
// map.put("departmenthead",departmentHeadByUser.getId());
// map.put("departmenthead",departmentHeadByUser.getId());
Integer res = depositoryRecordService.insertApplicationOutRecord(map,userToken);
if(res == 1) {
for (int i = 0; i < params.size(); i++) {
@ -221,7 +299,7 @@ public class DepositoryRecordController {
insert.put("quantity", map.get("quantity" + temp));
insert.put("applyRemark", map.get("applyRemark" + temp));
insert.put("code", map.get("code"));
insert.put("placeId", map.get("placeId" + temp));
insert.put("placeId", map.get("placeId"));
// 获取主订单编号
insert.put("parentId", map.get("id"));
// 插入子订单
@ -254,12 +332,107 @@ public class DepositoryRecordController {
return new RestResponse(list,depositoryRecordService.findApplicationInRecordPCountByCondition(map),200);
}
// 当前仓库中该用户的子订单详情
@GetMapping("/ApplicationOutMinByDid")
public RestResponse ApplicationOutMinByDid(@RequestParam Map<String,Object> map, HttpServletRequest request){
Integer depositoryId =ObjectFormatUtil.toInteger(map.get("depositoryId"));
// 0未完成1已完成
Integer stateOnView =ObjectFormatUtil.toInteger(map.get("state"));
UserByPort userToken = (UserByPort) request.getAttribute("userToken");
// 获取当前仓库信息
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(depositoryId);
// 获取当前用户要处理的记录信息
String minRecord = (String) redisTemplateForHash.opsForHash().get("user:"+userToken.getId(),"minRecord");
// 获取子订单键值
String[] split = minRecord.replace("[","").replace("]","").split(",");
List<SimpleApplicationOutMinRecordP> applicationOutRecordMinList = new ArrayList<>();
for (int i = 0; i < split.length; i++) {
//获取当前订单状态
String state = (String) redisTemplateForHash.opsForHash().get(split[i], "state");
if(Integer.compare(stateOnView,0) == 0 && !"1".equals(state)){
// 如果当前要查看的是未完成的并且当前订单不是未完成
continue;
}
if(Integer.compare(stateOnView,1) == 0 && !"2".equals(state)){
// 如果当前要查看的是已完成的并且当前订单不是已完成
continue;
}
if("1".equals(state)){
// 如果当前订单未完成
state = "进行中";
}else if("2".equals(state)){
// 如果当前订单已完成
state = "已完成";
}
// 获取子订单编码
String minRecordId = split[i].split(":")[1];
// 获取数据库中子订单信息
ApplicationOutRecordMin applicationOutMinById = depositoryRecordService.findApplicationOutMinById(ObjectFormatUtil.toInteger(minRecordId));
// 如果该子订单仓库是当前仓库
if(Integer.compare(applicationOutMinById.getDepositoryId(),depositoryId) == 0){
// 获取子订单对应主订单
ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(applicationOutMinById.getParentId());
// 获取申请人
UserByPort userByPort = PageController.FindUserById(applicationOutRecordPById.getApplicantId());
// 创建展示对象
SimpleApplicationOutMinRecordP simpleApplicationOutMinRecordP = new SimpleApplicationOutMinRecordP(applicationOutMinById);
// 获取申请的物料信息
Material materialById = materialService.findMaterialById(applicationOutMinById.getMid());
// 获取当前出库库位
Place placeByDid = placeService.findPlaceById(applicationOutMinById.getPlaceId());
simpleApplicationOutMinRecordP.setApplicantTime(DateUtil.TimeStampToDateTime(Long.valueOf(applicationOutRecordPById.getApplicantTime())));
simpleApplicationOutMinRecordP.setApplyRemark(applicationOutRecordPById.getApplyRemark());
simpleApplicationOutMinRecordP.setDepositoryId(depositoryRecordById.getId());
simpleApplicationOutMinRecordP.setDepositoryName(depositoryRecordById.getDname());
simpleApplicationOutMinRecordP.setMname(materialById.getMname());
simpleApplicationOutMinRecordP.setMcode(materialById.getCode());
simpleApplicationOutMinRecordP.setApplicantName(userByPort.getName());
simpleApplicationOutMinRecordP.setCode(applicationOutRecordPById.getCode());
simpleApplicationOutMinRecordP.setPcode(placeByDid.getCode());
simpleApplicationOutMinRecordP.setPid(placeByDid.getId());
simpleApplicationOutMinRecordP.setState(state);
applicationOutRecordMinList.add(simpleApplicationOutMinRecordP);
}
}
return new RestResponse(applicationOutRecordMinList,applicationOutRecordMinList.size(),200);
}
// 查看出库申请
@GetMapping("/applicationOutView")
public RestResponse findApplicationOutRecordByCondition(@RequestParam Map<String,Object> map){
// 获取对应主订单
List<ApplicationOutRecordP> list = depositoryRecordService.findApplicationOutRecordPByCondition(map);
for (int i = 0; i < list.size(); i++) {
list.get(i).setPrice(list.get(i).getPrice() / 100);
ApplicationOutRecordP outRecordP = list.get(i);
// 根据主订单获取所有子订单
List<ApplicationOutRecordMin> applicationOutMinByParentId = depositoryRecordService.findApplicationOutMinByParentId(outRecordP.getId());
StringBuilder mname = new StringBuilder();
StringBuilder mcode = new StringBuilder();
StringBuilder depositoryName = new StringBuilder();
Integer sumQuantity = 0;
Double sumPrice = 0.0;
for (int j = 0; j < applicationOutMinByParentId.size(); j++) {
// 获取子订单信息
ApplicationOutRecordMin applicationOutRecordMin = applicationOutMinByParentId.get(j);
// 获取出库物料信息
Material materialById = materialService.findMaterialById(applicationOutRecordMin.getMid());
// 获取出库物料仓库信息
Depository depository = depositoryService.findDepositoryRecordById(applicationOutRecordMin.getDepositoryId());
mname.append(materialById.getMname()).append(",");
mcode.append(materialById.getCode()).append(",");
depositoryName.append(depository.getDname()).append(",");
sumQuantity += applicationOutRecordMin.getQuantity();
sumPrice += (materialById.getPrice() / 100);
}
list.get(i).setMcode(mcode.toString());
list.get(i).setMname(mname.toString());
list.get(i).setDepositoryName(depositoryName.toString());
list.get(i).setQuantity(sumQuantity);
list.get(i).setPrice(sumPrice);
}
return new RestResponse(list,depositoryRecordService.findApplicationOutRecordPCountByCondition(map),200);
}
@ -289,18 +462,20 @@ public class DepositoryRecordController {
UserByPort userToken= (UserByPort) request.getAttribute("userToken");
List<Integer> mids = (List<Integer>) map.get("mids");
List<Integer> depositoryIds = (List<Integer>) map.get("depositoryIds");
List<String> placeCodes = (List<String>) map.get("placeCodes");
List<Object> nowmids = redisTemplate.opsForList().range("mids"+userToken.getId(), 0, -1);
List<Object> nowdepositoryIds = redisTemplate.opsForList().range("depositoryIds"+userToken.getId(), 0, -1);
for (int i = 0; i < mids.size(); i++) {
if(nowmids.contains(mids.get(i))){
continue;
}
redisTemplate.opsForList().leftPush("mids"+userToken.getId(), mids.get(i));
redisTemplate.opsForList().leftPush("depositoryIds"+userToken.getId(), depositoryIds.get(i));
redisTemplate.opsForList().leftPush("placeCodes"+userToken.getId(), placeCodes.get(i));
}
redisTemplate.expire("mids"+userToken.getId(),24 * 60 * 60, TimeUnit.SECONDS);
redisTemplate.expire("depositoryIds"+userToken.getId(),24 * 60 * 60, TimeUnit.SECONDS);
redisTemplate.expire("placeCodes"+userToken.getId(),24 * 60 * 60, TimeUnit.SECONDS);
return CrudUtil.postHandle(1,1);
}
@ -420,14 +595,22 @@ public class DepositoryRecordController {
}
List<ApplicationModel> list = new ArrayList<>();
for (int i = start; i < end; i++) {
// 获取物料编号
Integer mid =ObjectFormatUtil.toInteger(redisTemplate.opsForList().index("mids"+userToken.getId(),i));
// 获取仓库编号
Integer depositoryId =ObjectFormatUtil.toInteger(redisTemplate.opsForList().index("depositoryIds"+userToken.getId(),i));
// 获取库位编码
String placeCode =(String)(redisTemplate.opsForList().index("placeCodes"+userToken.getId(),i));
// 获取物料信息
Material materialById = materialService.findMaterialById(mid);
// 获取仓库信息
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(depositoryId);
ApplicationModel ap = new ApplicationModel();
ap.setDepositoryId(depositoryId);
ap.setDepositoryName(depositoryRecordById.getDname());
ap.setMid(mid);
ap.setPlaceCode(placeCode);
ap.setVersion(materialById.getVersion());
ap.setMname(materialById.getMname());
ap.setCode(materialById.getCode());
@ -457,9 +640,19 @@ public class DepositoryRecordController {
if("in".equals(type)){
success += depositoryRecordService.applicationIn(map);
}else if("out".equals(type)){
UserByPort departmentHeadByUser = findDepartmentHeadByUser(userToken);
map.put("departmenthead",departmentHeadByUser.getId());
success += depositoryRecordService.insertApplicationOutRecord(map,userToken);
// 获取部门负责人
// UserByPort departmentHeadByUser = findDepartmentHeadByUser(userToken);
// map.put("departmenthead",departmentHeadByUser.getId());
Integer res = depositoryRecordService.insertApplicationOutRecord(map,userToken); // 插入主订单
if(res == 1){ // 如果插入成功
Object id = map.get("id"); // 获取主订单编号
if(id != null){
map.remove("id");
map.put("parentId",id);
}
success += depositoryRecordService.insertApplicationOutMin(map);
}
}
if(success == 0){
return new RestResponse("",666,new StatusInfo("申请失败","超出最大存储容量"));
@ -476,24 +669,53 @@ public class DepositoryRecordController {
@PostMapping("/createMultiApplications")
public RestResponse createMultiApplications(@RequestBody Map<String,Object> map,HttpServletRequest request){
UserByPort userToken= (UserByPort) request.getAttribute("userToken");
// 获取要处理的类型
String type = (String) map.get("type");
Integer success = 0;
List<Integer> mids = (List<Integer>) map.get("mids");
List<Integer> depositoryIds = (List<Integer>) map.get("depositoryIds");
List<Object> quantitys = (List<Object>) map.get("quantitys");
List<String> placeCodes = (List<String>) map.get("placeCodes");
List<String> applyRemarks = (List<String>) map.get("applyRemarks");
List<Object> prices = (List<Object>) map.get("prices");
String errMsg = "";
Integer id = 0;
if("in".equals(type)){
for (int i = 0; i < mids.size(); i++) {
Integer mid = mids.get(i);
// 获取库位
String placeCode = placeCodes.get(i);
// 获取当前仓库编号
Integer depositoryId = depositoryIds.get(i);
String price = prices.get(i).toString();
// 获取当前申请数量
Integer integer = ObjectFormatUtil.toInteger(quantitys.get(i));
String quantity = integer.toString();
// 获取每个库位编码
String[] s = placeCode.split(" ");
// 先定义最终要使用的库位,默认是默认库位
Integer place = 0;
if(s.length > 1){
// 获取当前仓库所有库位
List<Place> placeByDid = placeService.findPlaceByDid(depositoryId);
// 遍历当前物料存储的库位
for (int j = 0; j < s.length; j++) {
Place place1 = placeByDid.get(j);
if(placeCode.equals(place1.getCode())){
// 如果当前物料存放在当前库位
if(place1.getMax() - place1.getQuantity() >= integer){
// 如果当前库位能够存放当前数量
place = place1.getId();
}
}
}
}
Integer mid = mids.get(i);
String price = prices.get(i).toString();
String applyRemark = applyRemarks.get(i);
Map<String,Object> inRecord = new HashMap<>();
inRecord.put("applicantId",userToken.getId());
inRecord.put("mid",mid);
inRecord.put("placeId",place);
inRecord.put("depositoryId",depositoryId);
inRecord.put("quantity",quantity);
inRecord.put("price",price);
@ -501,27 +723,113 @@ public class DepositoryRecordController {
success += depositoryRecordService.applicationIn(inRecord);
}
}else if("out".equals(type)){
Map<String,Object> mainRecord = new HashMap<>();
Integer sumQuantity = 0;
for (int i = 0; i < quantitys.size(); i++) {
Integer integer = ObjectFormatUtil.toInteger(quantitys.get(i));
sumQuantity += integer;
}
// 获取部门负责人
// UserByPort departmentHeadByUser = findDepartmentHeadByUser(userToken);
mainRecord.put("applicantId",userToken.getId());
mainRecord.put("applyRemark","");
mainRecord.put("quantity",sumQuantity.toString());
// mainRecord.put("departmenthead",departmentHeadByUser.getId());
// 插入主表
depositoryRecordService.insertApplicationOutRecord(mainRecord,userToken);
id = ObjectFormatUtil.toInteger(mainRecord.get("id"));
for (int i = 0; i < mids.size(); i++) {
Integer mid = mids.get(i);
Integer integer = ObjectFormatUtil.toInteger(quantitys.get(i));
// 获取当前仓库编号
Integer depositoryId = depositoryIds.get(i);
String quantity = integer.toString();
String applyRemark = applyRemarks.get(i);
Map<String,Object> outRecord = new HashMap<>();
outRecord.put("quantity",quantity);
outRecord.put("mid",mid);
outRecord.put("applicantId",userToken.getId());
outRecord.put("applyRemark",applyRemark);
UserByPort departmentHeadByUser = findDepartmentHeadByUser(userToken);
outRecord.put("departmenthead",departmentHeadByUser.getId());
success += depositoryRecordService.insertApplicationOutRecord(outRecord,userToken);
// 获取库位
String placeCode = placeCodes.get(i);
// 获取每个库位编码
String[] s = placeCode.split(" ");
Integer place = 0;
// 用于标志该库位是否可以出库
Boolean flag = false;
if(s.length > 1){
// 获取当前仓库所有库位
List<Place> placeByDid = placeService.findPlaceByDid(depositoryId);
// 遍历当前物料存储的库位
for (int j = 1; j < s.length; j++) {
// 获取当前库位
for (int k = 0; k < placeByDid.size(); k++) {
Place place1 = placeByDid.get(k);
if(s[j].equals(place1.getCode())){
// 如果当前物料存放在当前库位
// 获取当前物料在当前库位中的数目
Integer quantityByMidAndPid = placeService.findQuantityByMidAndPid(mid, place1.getId());
if(quantityByMidAndPid > integer){
// 如果可以出库
place = place1.getId();
flag = true;
break;
}
}
}
}
}
if(Integer.compare(0,place) == 0){
// 如果当前库位是默认库位
Integer quantityByMidAndPid = placeService.findQuantityByMidAndPid(mid, 0);
if(quantityByMidAndPid > integer){
// 如果默认库位中该物料数量可以出库
flag = true;
}
}
if(flag) {
String applyRemark = applyRemarks.get(i);
Map<String, Object> outRecord = new HashMap<>();
outRecord.put("quantity", quantity);
outRecord.put("mid", mid);
outRecord.put("parentId", mainRecord.get("id"));
outRecord.put("code", mainRecord.get("code"));
outRecord.put("placeId",place);
success += depositoryRecordService.insertApplicationOutMin(outRecord);
}else{
// 获取失败的物料信息
Material materialById = materialService.findMaterialById(mid);
// 获取失败的仓库信息
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(depositoryId);
errMsg += materialById.getMname() + "在"+depositoryRecordById.getDname()+"出库数量为"+quantity +"失败,数量不足;";
}
}
}
if(success == 0){
depositoryRecordService.deleteApplicationOutRecordById(1);
return new RestResponse("",666,new StatusInfo("申请失败","超出最大存储容量"));
}
if(success < mids.size()){
// 如果申请成功数量小于申请数量
return new RestResponse(errMsg,1234,new StatusInfo("出库失败","数量不足"));
}
return CrudUtil.postHandle(success,mids.size());
}
// 确认将物料出库
@PostMapping("/isCheckOut")
public RestResponse isCheckOut(@RequestBody Map<String,Object> map,HttpServletRequest request){
UserByPort userToken = (UserByPort) request.getAttribute("userToken");
Integer placeId =ObjectFormatUtil.toInteger(map.get("placeId"));
if(placeId == null){
// 如果是仓库,则使用默认库位
map.put("placeId",0);
}
Integer integer = depositoryRecordService.completeApplicationOutMinRecord(map, userToken);
if(integer == 1){
return new RestResponse("",200,new StatusInfo("出库成功","出库成功"));
}else{
return new RestResponse("",500,new StatusInfo("出库失败","出库失败,请联系开发人员"));
}
}
/**
* 获取当前登录用户的部门负责人
* @param user
@ -556,4 +864,8 @@ public class DepositoryRecordController {
}

19
src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java

@ -54,6 +54,12 @@ public class MaterialController {
return new RestResponse(materialPByCondition,materialService.findCountByCondition(map),200);
}
/**
* 查询库存
* @param map
* @param request
* @return
*/
@GetMapping("/findInventory")
public RestResponse findInventory(@RequestParam Map<String,Object> map,HttpServletRequest request){
UserByPort userToken= (UserByPort) request.getAttribute("userToken");
@ -169,9 +175,16 @@ public class MaterialController {
return new RestResponse(map,1,200);
}
/**
* 根据物料编码获取物料
* @param map
* @param request
* @return
*/
@GetMapping("/findMatrialByCode")
public RestResponse findMatrialByCode(@RequestParam Map<String,Object> map,HttpServletRequest request){
UserByPort userToken= (UserByPort) request.getAttribute("userToken");
// 获取当前部门仓库
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString());
Map<String,Object> param = new HashMap<>();
String code = map.get("code").toString();
@ -182,14 +195,16 @@ public class MaterialController {
param.put("code",code);
List<MaterialP> materialPByCondition = new ArrayList<>();
if("out".equals(type)) {
// 如果是出库
for (int i = 0; i < depositoryByAdminorg.size(); i++) {
param.put("depositoryId", depositoryByAdminorg.get(i).getId());
// 查找当前用户部门仓库中是否存在该物料
materialPByCondition = materialService.findInventory(param);
if (materialPByCondition.size() > 0) {
break;
}
}
}else{
}else{ // 如果是入库
materialPByCondition = materialService.findMaterialPByCondition(param);
}
MaterialP mp = null;
@ -301,7 +316,7 @@ public class MaterialController {
if(inventory.size() > 0){ // 如果有库存
for (int j = 0; j < inventory.size(); j++) {
MaterialP materialP = inventory.get(j);
if(quantity < materialP.getQuantity()){ // 如果当前数量合适则跳出循环
if(quantity <= materialP.getQuantity()){ // 如果当前数量合适则跳出循环
flag = true;
break;
}

126
src/main/java/com/dreamchaser/depository_manage/controller/PageController.java

@ -66,6 +66,10 @@ public class PageController {
@Autowired
private RedisTemplate<Object,Object> redisTemplate;
@Autowired
private RedisTemplate<String,String> redisTemplateForHash;
public static JSONObject Captcha(){
@ -888,14 +892,17 @@ public class PageController {
param.put("depositoryId",depositoryRecordById.getId());
List<MaterialAndPlace> placeAndMaterialByPid = placeService.findPlaceAndMaterialByPid(placeById.getId());
StringBuilder mname = new StringBuilder();
StringBuilder mcodeList = new StringBuilder();
StringBuilder midList = new StringBuilder();
for (int i = 0; i < placeAndMaterialByPid.size(); i++) {
Material materialById = materialService.findMaterialById(placeAndMaterialByPid.get(i).getMid());
mname.append(materialById.getMname()).append(", ");
midList.append(materialById.getId()).append(",");
mcodeList.append(materialById.getCode()).append(",");
}
param.put("mname",mname);
param.put("midList",midList);
param.put("mname",mname.toString());
param.put("midList",midList.toString());
param.put("mcodeList",mcodeList.toString());
String context = JSONObject.toJSONString(param);
String qrCode = "";
try {
@ -1027,7 +1034,42 @@ public class PageController {
public ModelAndView application_review(Integer id) {
ModelAndView mv = new ModelAndView();
mv.setViewName("pages/application/application-review");
// 获取主订单信息
ApplicationOutRecordP recordP = depositoryRecordService.findApplicationOutRecordPById(id);
// 获取所有子订单
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordService.findApplicationOutRecordMinByParent(recordP.getId());
// 展示物料名
StringBuilder mname = new StringBuilder();
// 展示物料编码
StringBuilder mcode = new StringBuilder();
// 展示出库的仓库名
StringBuilder depositoryName = new StringBuilder();
// 展示出库的库位编码
StringBuilder placeCode = new StringBuilder();
// 当前订单总数
Integer sumQuantity = 0;
// 当前总额
Double sumPrice = 0.0;
for (int i = 0; i < applicationOutRecordMinByParent.size(); i++) {
// 获取子订单信息
ApplicationOutRecordMin applicationOutRecordMin = applicationOutRecordMinByParent.get(i);
// 获取出库物料信息
Material materialById = materialService.findMaterialById(applicationOutRecordMin.getMid());
// 获取出库物料仓库信息
Depository depository = depositoryService.findDepositoryRecordById(applicationOutRecordMin.getDepositoryId());
// 获取出库库位
Place placeById = placeService.findPlaceById(applicationOutRecordMin.getPlaceId());
if(placeById != null) {
placeCode.append(placeById.getCode()).append(",");
}
mname.append(materialById.getMname()).append(",");
mcode.append(materialById.getCode()).append(",");
depositoryName.append(depository.getDname()).append(",");
sumQuantity += applicationOutRecordMin.getQuantity();
sumPrice += (materialById.getPrice() / 100);
}
// 申请人
UserByPort userByPort = FindUserById(recordP.getApplicantId());
// 部门负责人
@ -1055,7 +1097,14 @@ public class PageController {
recordP.setDepositoryManagerName(depositoryManagerNames);
recordP.setApplicantName(userByPort.getName());
recordP.setDepartmentheadName(departmenthead.getName());
recordP.setPrice(recordP.getPrice() / 100);
recordP.setMcode(mcode.toString());
recordP.setMname(mname.toString());
recordP.setDepositoryName(depositoryName.toString());
recordP.setQuantity(sumQuantity);
recordP.setPrice(sumPrice);
if(recordP.getPrice()!=null) {
recordP.setPrice(recordP.getPrice() / 100);
}
mv.addObject("record", recordP);
return mv;
}
@ -1078,6 +1127,8 @@ public class PageController {
return mv;
}
// 跳转到出库详情
@GetMapping("/ApplicationOutView")
public ModelAndView ApplicationOutView(Integer id) {
ModelAndView mv = new ModelAndView();
@ -1087,12 +1138,42 @@ public class PageController {
ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(id);
// 获取出库子单
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordService.findApplicationOutRecordMinByParent(applicationOutRecordPById.getId());
// 展示物料名
StringBuilder mname = new StringBuilder();
// 展示物料编码
StringBuilder mcode = new StringBuilder();
// 展示出库的仓库名
StringBuilder depositoryName = new StringBuilder();
// 展示出库的库位编码
StringBuilder placeCode = new StringBuilder();
// 当前订单总数
Integer sumQuantity = 0;
// 当前总额
Double sumPrice = 0.0;
for (int i = 0; i < applicationOutRecordMinByParent.size(); i++) {
// 获取子订单信息
ApplicationOutRecordMin applicationOutRecordMin = applicationOutRecordMinByParent.get(i);
// 获取出库物料信息
Material materialById = materialService.findMaterialById(applicationOutRecordMin.getMid());
// 获取出库物料仓库信息
Depository depository = depositoryService.findDepositoryRecordById(applicationOutRecordMin.getDepositoryId());
// 获取出库库位
Place placeById = placeService.findPlaceById(applicationOutRecordMin.getPlaceId());
if(placeById != null) {
placeCode.append(placeById.getCode()).append(",");
}
mname.append(materialById.getMname()).append(",");
mcode.append(materialById.getCode()).append(",");
depositoryName.append(depository.getDname()).append(",");
sumQuantity += applicationOutRecordMin.getQuantity();
sumPrice += (materialById.getPrice() / 100);
}
// 申请人
UserByPort userByPort = FindUserById(applicationOutRecordPById.getApplicantId());
// 部门负责人
UserByPort departmenthead = FindUserById(applicationOutRecordPById.getDepartmenthead());
// 仓库管理员
// 仓储中心负责人
String manager = applicationOutRecordPById.getDepositoryManager();
String[] depositoryManagerId = new String[0];
if(manager != null){
@ -1112,11 +1193,12 @@ public class PageController {
applicationOutRecordPById.setApplicantTime(DateUtil.TimeStampToDateTime(Long.valueOf(applicationOutRecordPById.getApplicantTime())));
applicationOutRecordPById.setDepartmentheadTime(DateUtil.TimeStampToDateTime(Long.valueOf(applicationOutRecordPById.getDepartmentheadTime())));
applicationOutRecordPById.setDepositoryManagerTime(DateUtil.TimeStampToDateTime(Long.valueOf(applicationOutRecordPById.getDepositoryManagerTime())));
applicationOutRecordPById.setPrice(applicationOutRecordPById.getPrice() / 100);
if(applicationOutRecordPById.getPlaceId()!=null) {
Place placeById = placeService.findPlaceById(applicationOutRecordPById.getPlaceId());
applicationOutRecordPById.setPCode(placeById.getCode());
}
applicationOutRecordPById.setPrice(sumPrice);
applicationOutRecordPById.setQuantity(sumQuantity);
applicationOutRecordPById.setMname(mname.toString());
applicationOutRecordPById.setMcode(mcode.toString());
applicationOutRecordPById.setDepositoryName(depositoryName.toString());
applicationOutRecordPById.setPCode(placeCode.toString());
mv.addObject("record", applicationOutRecordPById);
} else {
throw new MyException("缺少必要参数!");
@ -1417,6 +1499,7 @@ public class PageController {
}
// 跳转到添加权限界面
@GetMapping("/postRoleAdd")
public ModelAndView PostRoleAdd(Integer id) {
ModelAndView mv = new ModelAndView();
@ -1428,10 +1511,23 @@ public class PageController {
return mv;
}
// 跳转到扫码界面
@GetMapping("/scanQrCode")
public String scanQrCode(){
return "pages/scanQrCode/ScanQrCode";
}
// 跳转到扫码出库界面
@GetMapping("/scanQrCodeByOut")
public ModelAndView scanQrCodeByOut(Integer id,HttpServletRequest request){
ModelAndView mv = new ModelAndView();
// 获取当前要处理的子订单
ApplicationOutRecordMin applicationOutMinById = depositoryRecordService.findApplicationOutMinById(id);
mv.setViewName("pages/scanQrCode/scanQrCodeOut");
Material materialById = materialService.findMaterialById(applicationOutMinById.getMid());
mv.addObject("materialById",materialById);
mv.addObject("record",applicationOutMinById);
return mv;
}
// 获取扫描结果并跳转到入库
@GetMapping("/application_in_scanQrCode")
@ -1482,4 +1578,14 @@ public class PageController {
mv.setViewName("pages/application/application-out_scanQrCode");
return mv;
}
// 当前仓库中该用户的子订单详情
@GetMapping("/ApplicationOutMinByDid")
public ModelAndView ApplicationOutMinByDid(Integer depositoryId,Integer state,HttpServletRequest request){
ModelAndView mv = new ModelAndView();
mv.addObject("depositoryId",depositoryId);
mv.addObject("state",state);
mv.setViewName("pages/application/application-out_min");
return mv;
}
}

5
src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecordMin.java

@ -44,4 +44,9 @@ public class ApplicationOutRecordMin {
*/
private Integer parentId;
/**
* 子订单状态1未完成2完成
*/
private Integer state;
}

21
src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java

@ -306,4 +306,25 @@ public interface DepositoryRecordMapper {
* @return
*/
List<ApplicationOutRecordMin> findApplicationOutRecordMinByParent(Integer parentId);
/**
* 修改子表记录
* @param map
* @return
*/
Integer updateApplicationOutRecordMin(Map<String,Object> map);
/**
* 修改子表记录
* @param applicationOutRecordMin
* @return
*/
Integer updateApplicationOutRecordMin(ApplicationOutRecordMin applicationOutRecordMin);
/**
* 根据条件获取子订单
* @param map
* @return
*/
List<ApplicationOutRecordMin> findApplicationOutMinByCondition(Map<String,Object> map);
}

75
src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -97,7 +97,7 @@
<!-- 出库子订单-->
<resultMap id="applicationOutRecordMin" type="com.dreamchaser.depository_manage.entity.ApplicationOutRecordMin">
<id property="id" column="aorid" jdbcType="INTEGER"/>
<id property="id" column="id" jdbcType="INTEGER"/>
<result column="mid" property="mid" jdbcType="INTEGER" />
<result column="depositoryId" property="depositoryId" jdbcType="INTEGER" />
<result column="placeId" property="placeId" jdbcType="INTEGER" />
@ -600,12 +600,10 @@
<!-- 插入一条出库记录-->
<insert id="insertApplicationOutRecord" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into application_out_record
(id,mid,depository_id,applicant_id,applicant_time,code,price,quantity,departmenthead,departmenthead_pass,departmenthead_time,
departmenthead_messgae,depository_manager,depository_manager_pass,depository_manager_time,depository_manager_message,apply_remark,state,istransfer,transferId,placeId)
(id,applicant_id,applicant_time,code,price,quantity,departmenthead,departmenthead_pass,departmenthead_time,
departmenthead_messgae,depository_manager,depository_manager_pass,depository_manager_time,depository_manager_message,apply_remark,state,istransfer,transferId,placeId,pass)
values(
#{id},
#{mid},
#{depositoryId},
#{applicantId},
#{applicantTime},
#{code},
@ -644,7 +642,8 @@
#{state},
#{istransfer},
#{transferId},
#{placeId}
#{placeId},
#{pass}
)
</insert>
@ -673,6 +672,35 @@
</select>
<select id="findApplicationOutMinByCondition" parameterType="int" resultMap="applicationOutRecordMin">
select
<include refid="ApplicationOutRecordMinInfo" />
from application_out_record_min as aorm
where 1 = 1
<if test="id != null and id != ''">
and aorm.id = #{id}
</if>
<if test="mid != null and mid != ''">
and aorm.mid = #{mid}
</if>
<if test="placeId != null">
and aorm.placeId = #{placeId}
</if>
<if test="quantity != null">
and aorm.quantity = #{quantity}
</if>
<if test="code != null">
and aorm.code = #{code}
</if>
<if test="checkId != null">
and aorm.checkId = #{checkId}
</if>
<if test="parentId != null">
and aorm.parentId = #{parentId}
</if>
</select>
<select id="findApplicationOutRecordMinByParent" parameterType="int" resultMap="applicationOutRecordMin">
select
<include refid="ApplicationOutRecordMinInfo" />
@ -823,6 +851,36 @@
WHERE id = #{id}
</update>
<!-- 修改子单-->
<update id="updateApplicationOutRecordMin">
update application_out_record_min
<set>
<if test="mid != '' and mid != null">
mid = #{mid},
</if>
<if test="depositoryId != '' and depositoryId != null">
depositoryId = #{depositoryId},
</if>
<if test="placeId != null">
placeId = #{placeId},
</if>
<if test="quantity != null">
quantity = #{quantity},
</if>
<if test="code != null">
code = #{code},
</if>
<if test="checkId != null">
checkId = #{checkId},
</if>
<if test="parentId != null ">
parentId = #{parentId}
</if>
where id = #{id}
</set>
</update>
<!-- 修改数据-->
<update id="updateApplicationOutRecord" parameterType="map">
UPDATE application_out_record
@ -876,7 +934,10 @@
state = #{state},
</if>
<if test="placeId != null">
placeId = #{placeId}
placeId = #{placeId},
</if>
<if test="pass != null and pass != ''">
pass = #{pass}
</if>
</set>
WHERE id = #{id}

2
src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

@ -245,7 +245,7 @@
<!-- 插入数据 -->
<insert id="insertMaterial" parameterType="map">
<insert id="insertMaterial" parameterType="map" useGeneratedKeys="true" keyProperty="id">
INSERT INTO material (
id, depository_id, mname, quantity, price, type_id,code,unit,version,texture,amounts,depositoryCode
) VALUES (

8
src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.java

@ -146,4 +146,12 @@ public interface PlaceMapper {
*/
Integer updateMaterialAndPlace(Map<String,Object> map);
Integer updateMaterialAndPlace(MaterialAndPlace mp);
/**
* 获取当前库位当前物料的数量
* @param map
* @return
*/
Integer findQuantityByMidAndPid(Map<String,Object> map);
}

7
src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml

@ -146,12 +146,19 @@
FROM place p WHERE 1 = 1 and p.did = #{did}
</select>
<select id="findPlaceByMid" parameterType="int" resultMap="placeMap">
SELECT
<include refid="allColumns" />
FROM materialandplace mp left join place p on p.id = mp.pid WHERE 1 = 1 and mp.mid = #{mid}
</select>
<select id="findQuantityByMidAndPid" parameterType="map" resultType="int">
select quantity
from materialandplace
where pid = #{pid} and mid = #{mid}
</select>
<!-- 根据主键查询信息 -->
<select id="findPlaceById" resultMap="placeMap" parameterType="int">
SELECT

5
src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationModel.java

@ -54,4 +54,9 @@ public class ApplicationModel {
* 单价
*/
private Double price;
/**
* 库位编码
*/
private String placeCode;
}

75
src/main/java/com/dreamchaser/depository_manage/pojo/SimpleApplicationOutMinRecordP.java

@ -0,0 +1,75 @@
package com.dreamchaser.depository_manage.pojo;
import com.dreamchaser.depository_manage.entity.ApplicationOutRecordMin;
import lombok.Data;
import java.math.BigInteger;
// 用于子订单展示
@Data
public class SimpleApplicationOutMinRecordP {
/** 记录id */
private Integer id;
/** 申请人姓名 */
private String applicantName;
/** 申请备注 */
private String applyRemark;
/** 申请时间 */
private String applicantTime;
/**
* 申请物料编码
*/
private BigInteger mcode;
/**
* 订单编码
*/
private String code;
/**
* 申请物料名
*/
private String mname;
/**
* 主订单编号
*/
private Integer parentId;
/**
* 申请数目
*/
private Integer quantity;
/**
* 仓库编号
*/
private Integer depositoryId;
/**
* 仓库名
*/
private String depositoryName;
/**
* 库位编号
*/
private Integer pid;
/**
* 库位编码
*/
private String pcode;
/**
* 子订单状态
*/
private String state;
public SimpleApplicationOutMinRecordP(ApplicationOutRecordMin applicationOutRecordMin) {
this.id = applicationOutRecordMin.getId();
this.parentId = applicationOutRecordMin.getParentId();
this.quantity = applicationOutRecordMin.getQuantity();
}
}

30
src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java

@ -313,4 +313,34 @@ public interface DepositoryRecordService {
* @return
*/
List<ApplicationOutRecordMin> findApplicationOutRecordMinByParent(Integer id);
/**
* 根据主键获取子表信息
* @param id
* @return
*/
ApplicationOutRecordMin findApplicationOutMinById(Integer id);
/**
* 根据条件获取子订单
* @param map
* @return
*/
List<ApplicationOutRecordMin> findApplicationOutMinByCondition(Map<String,Object> map);
/**
* 根据主订单获取子订单
* @param parentId
* @return
*/
List<ApplicationOutRecordMin> findApplicationOutMinByParentId(Integer parentId);
/**
* 完成对应的子订单
* @param map
* @param userByPort
* @return
*/
Integer completeApplicationOutMinRecord(Map<String,Object> map,UserByPort userByPort);
}

9
src/main/java/com/dreamchaser/depository_manage/service/PlaceService.java

@ -110,6 +110,11 @@ public interface PlaceService {
Integer addMaterialOnPlace(Map<String,Object> map);
/**
* 获取当前物料在当前库位的数量
* @param mid
* @param pid
* @return
*/
Integer findQuantityByMidAndPid(Integer mid,Integer pid);
}

1
src/main/java/com/dreamchaser/depository_manage/service/UserService.java

@ -147,4 +147,5 @@ public interface UserService {
String FindDepositoryByUserId(Integer id);
}

459
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -28,6 +28,7 @@ import cn.hutool.core.lang.Snowflake;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -59,7 +60,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
private RedissonClient redissonClient;
/**
* 提交申请插入一条仓库调度记录
*
@ -96,7 +96,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
temp.put("dcode", depositoryRecordById.getCode());
// 获取当前仓库库存
Double Inventory = depositoryMapper.getToDayInventoryByDName(temp);
String code = createCode(depositoryRecordById.getDname(), "InOrderNumber","in","");//构造单号
String code = createCode(depositoryRecordById.getDname(), "InOrderNumber", "in", "");//构造单号
Double quantity = Double.parseDouble((String) map.get("quantity"));
Double price = Double.parseDouble((String) map.get("price"));
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
@ -122,8 +122,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前物料
if (materialByCondition.size() > 0) { // 如果当前存在
Material mt = materialByCondition.get(0);
map.put("oldPrice",mt.getPrice());
map.put("mid",mt.getId());
map.put("oldPrice", mt.getPrice());
map.put("mid", mt.getId());
mt.setAmounts(mt.getAmounts() + amounts);
mt.setQuantity((int) (mt.getQuantity() + quantity));
mt.setPrice(avgPrice);
@ -148,7 +148,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
}
/**
* 插入一条出库记录
*
@ -156,33 +155,39 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return
*/
@Override
public Integer insertApplicationOutRecord(Map<String, Object> map,UserByPort userToken) {
public Integer insertApplicationOutRecord(Map<String, Object> map, UserByPort userToken) {
String placeId = (String) map.get("placeId");
if("".equals(placeId) || "0".equals(placeId)){
map.put("placeId",0);
if ("".equals(placeId) || "0".equals(placeId) || placeId == null) {
map.put("placeId", 0);
}
Double quantity = Double.parseDouble((String) map.get("quantity"));
Long time = DateUtil.DateTimeToTimeStamp(DateUtil.getSimpleTime(new Date()));
map.put("applicantTime", time);
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
// 获取当前物料
Material materialById = materialMapper.findMaterialById(mid);
int amounts = (int) ((materialById.getPrice() / 100) * quantity * 100);
map.put("price", amounts);
map.put("state", "待部门负责人审核");
String dname = "";
map.put("istransfer", 2);
Map<String, Object> update = new HashMap<>();
update.put("id", materialById.getId());
Integer numberOfTemporary = materialById.getNumberOfTemporary();
if (numberOfTemporary == null) {
numberOfTemporary = 0;
map.put("state", "待部门负责人审核");
if (mid != null) {
// 获取当前物料
Material materialById = materialMapper.findMaterialById(mid);
int amounts = (int) ((materialById.getPrice() / 100) * quantity * 100);
map.put("price", amounts);
Map<String, Object> update = new HashMap<>();
update.put("id", materialById.getId());
Integer numberOfTemporary = materialById.getNumberOfTemporary();
if (numberOfTemporary == null) {
numberOfTemporary = 0;
}
update.put("numberOfTemporary", numberOfTemporary + quantity);
materialMapper.updateMaterial(update);
Depository depositoryRecordById = depositoryMapper.findDepositoryRecordById(materialById.getDepositoryId());
dname = depositoryRecordById.getDname();
}
update.put("numberOfTemporary", numberOfTemporary + quantity);
materialMapper.updateMaterial(update);
Depository depositoryRecordById = depositoryMapper.findDepositoryRecordById(materialById.getDepositoryId());
Administration company = PageController.getCompany(userToken.getMaindeparment());
String code = createCode(depositoryRecordById.getDname(), "outOrderNumber","out",company.getName());
String code = createCode(dname, "outOrderNumber", "out", company.getName());
map.put("code", code);
map.put("pass", 3);
return depositoryRecordMapper.insertApplicationOutRecord(map);
}
@ -250,37 +255,37 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前物料基本信息
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Material materialById = materialMapper.findMaterialById(mid);
if(placeById.getMax() - placeById.getQuantity() > quantity){
if (placeById.getMax() - placeById.getQuantity() > quantity) {
// 如果当前库位还能存放
// 入库
Integer integer = applicationIn(map);
if(integer != 1){
if (integer != 1) {
return -1;
}
// 获取当前库存记录
Map<String, Object> param = new HashMap<>();
param.put("code", materialById.getCode());
param.put("mname", materialById.getMname());
if(placeId == 0){
param.put("depositoryId",map.get("depositoryId"));
}else {
if (placeId == 0) {
param.put("depositoryId", map.get("depositoryId"));
} else {
param.put("depositoryId", placeById.getDid());
}
List<Material> inventory = materialMapper.findInventory(param);
Material material = inventory.get(0);
Map<String,Object> insert = new HashMap<>();
insert.put("mid",material.getId());
insert.put("pid",placeById.getId());
Map<String, Object> insert = new HashMap<>();
insert.put("mid", material.getId());
insert.put("pid", placeById.getId());
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(insert);
if(placeAndMaterialByMidAndPid == null){
if (placeAndMaterialByMidAndPid == null) {
// 如果没有当前记录
insert.put("quantity",quantity);
insert.put("quantity", quantity);
// 插入记录
placeMapper.addMaterialOnPlace(insert);
}else{
} else {
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity);
// 修改数量
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
@ -288,13 +293,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 修改当前库位数量
placeById.setQuantity(placeById.getQuantity() + quantity);
return placeMapper.UpdatePlace(placeById);
}else{
} else {
return -1;
}
}
/**
* 将刚入库的记录删除
*
* @param map
* @return
*/
@ -308,34 +314,34 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Material materialById = materialMapper.findMaterialById(mid);
Object oldPrice1 = map.get("oldPrice");
Double oldPrice = 0.0;
if(oldPrice1 != null) {
oldPrice = Double.parseDouble(oldPrice1.toString());
if (oldPrice1 != null) {
oldPrice = Double.parseDouble(oldPrice1.toString());
}
Double price = Double.parseDouble(map.get("price").toString());
Integer id = ObjectFormatUtil.toInteger(map.get("id"));
String deleteType = map.get("delete").toString();
Map<String,Object> params = new HashMap<>();
params.put("code",materialById.getCode());
params.put("depositoryId",depositoryId);
Map<String, Object> params = new HashMap<>();
params.put("code", materialById.getCode());
params.put("depositoryId", depositoryId);
List<Material> materialByCondition = materialMapper.findMaterialByCondition(params);
if(materialByCondition.size() < 1){
if (materialByCondition.size() < 1) {
throw new MyException("出现未知错误,联系开发人员");
}
if("in".equals(deleteType)){
if ("in".equals(deleteType)) {
// 删除入库记录
depositoryRecordMapper.deleteApplicationInRecordById(id);
// 将库存还原
Material material = materialByCondition.get(0);
Map<String,Object> update = new HashMap<>();
update.put("quantity",material.getQuantity() - quantity);
update.put("price",oldPrice);
update.put("amounts",material.getAmounts() - quantity * price);
update.put("id",material.getId());
Map<String, Object> update = new HashMap<>();
update.put("quantity", material.getQuantity() - quantity);
update.put("price", oldPrice);
update.put("amounts", material.getAmounts() - quantity * price);
update.put("id", material.getId());
return materialMapper.updateMaterial(update);
}else if("out".equals(deleteType)){
} else if ("out".equals(deleteType)) {
return null;
}else {
} else {
throw new MyException("请求参数错误");
}
@ -343,16 +349,21 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
/**
* 插入一条出库子订单
*
* @param map
* @return
*/
@Override
public Integer insertApplicationOutMin(Map<String, Object> map) {
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Material materialById = materialMapper.findMaterialById(mid);
map.put("depositoryId", materialById.getDepositoryId());
return depositoryRecordMapper.insertApplicationOutRecordMin(map);
}
/**
* 根据主表获取所有子表
*
* @param id
* @return
*/
@ -361,6 +372,184 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
return depositoryRecordMapper.findApplicationOutRecordMinByParent(id);
}
/**
* 根据主键获取子表信息
*
* @param id
* @return
*/
@Override
public ApplicationOutRecordMin findApplicationOutMinById(Integer id) {
return depositoryRecordMapper.findApplicationOutMinById(id);
}
/**
* 根据条件获取子订单
*
* @param map
* @return
*/
@Override
public List<ApplicationOutRecordMin> findApplicationOutMinByCondition(Map<String, Object> map) {
return depositoryRecordMapper.findApplicationOutMinByCondition(map);
}
/**
* 根据主订单获取子订单
* @param parentId
* @return
*/
@Override
public List<ApplicationOutRecordMin> findApplicationOutMinByParentId(Integer parentId) {
Map<String,Object> map = new HashMap<>();
map.put("parentId",parentId);
return depositoryRecordMapper.findApplicationOutMinByCondition(map);
}
/**
* 完成对应的子订单
*
* @param param
* @param userByPort
* @return
*/
@Override
public Integer completeApplicationOutMinRecord(Map<String,Object> param, UserByPort userByPort) {
Integer id = ObjectFormatUtil.toInteger(param.get("id"));
// 获取要完成的子订单
ApplicationOutRecordMin applicationOutMinById = depositoryRecordMapper.findApplicationOutMinById(id);
// 获取子订单对应的主订单
ApplicationOutRecordP record = depositoryRecordMapper.findApplicationOutRecordPById(applicationOutMinById.getParentId());
// 设置标志位
boolean flag = true;
// 设置最终返回值
int result = 0;
// 获取库存转移标志位
Integer istransfer = record.getIstransfer();
// 获取出库库位
Integer placeId = ObjectFormatUtil.toInteger(param.get("placeId"));
if (istransfer == 1) {// 如果是库存转移
// 获取库存转移订单
TransferRecord transferRecordById = transferRecordMapper.findTransferRecordById(record.getTransferId());
placeId = transferRecordById.getFromPlaceId();// 获取转出库位
}
MaterialAndPlace placeAndMaterialByMidAndPid = null;
if (placeId != 0) { // 如果不是默认库位
Map<String, Object> params = new HashMap<>();
params.put("mid", applicationOutMinById.getMid());
params.put("pid", placeId);
// 获取当前物料所存放库位的数量
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(params);
if (placeAndMaterialByMidAndPid.getQuantity() < record.getQuantity()) {
// 如果当前库位数量不足
flag = false;
}
} else { // 如果是默认库位
Map<String, Object> params = new HashMap<>();
params.put("mid", applicationOutMinById.getMid());
params.put("pid", 0);
// 获取当前物料在默认库位中的数量
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(params);
if (placeAndMaterialByMidAndPid.getQuantity() < record.getQuantity()) {
// 如果当前库位数量不足
flag = false;
}
}
// 获取出库物料具体信息
Material material = materialMapper.findMaterialById(applicationOutMinById.getMid());
// 如果物料数量可以出库并且库位数量充足
if (material.getQuantity() >= record.getQuantity() && flag) {
// 当前出库金额
Double sum = material.getPrice() * record.getQuantity();
material.setAmounts(material.getAmounts() - sum);
material.setQuantity(material.getQuantity() - record.getQuantity());
material.setNumberOfTemporary(material.getNumberOfTemporary() - record.getQuantity());
// 修改物料信息
materialMapper.updateMaterial(material);
if (placeAndMaterialByMidAndPid != null) { //如果库位不为空
// 修改当前库位存放物料的数量
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - record.getQuantity());
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
}
// 修改库位数量
Place placeById = placeMapper.findPlaceById(placeId);
placeById.setQuantity(placeById.getQuantity() - record.getQuantity());
placeMapper.UpdatePlace(placeById);
String redisMinRecordKey = "minRecord:"+id; // 设置redis中子订单键值
// 修改redis中本子订单状态
redisTemplate.opsForHash().put(redisMinRecordKey,"state","2");
// 修改redis中本子订单完成人
redisTemplate.opsForHash().put(redisMinRecordKey,"manager",userByPort.getId().toString());
// 获取出库仓库信息
Depository depositoryRecordById = depositoryMapper.findDepositoryRecordById(applicationOutMinById.getDepositoryId());
// 设置子订单新编码
// 获取主订单单号
StringBuilder code = new StringBuilder(record.getCode());
// 获取申请用户信息
UserByPort applicantUser = PageController.FindUserById(record.getApplicantId());
// 获取申请用户行政组织
Administration company = PageController.getCompany(applicantUser.getMaindeparment());
// 获取部门名称简写
String conpanyName = WordUtil.getPinYinHeadChar(company.getName());
// 获取仓库名称简写
String depositoryName = WordUtil.getPinYinHeadChar(depositoryRecordById.getDname());
// 获取部门名称在单号的起始位置
int index = code.indexOf(conpanyName);
// 生产新子订单编号
String newCode = code.replace(index,index+conpanyName.length(),depositoryName).toString();
// 设置完成人
applicationOutMinById.setCheckId(userByPort.getId());
// 设置新编码
applicationOutMinById.setCode(newCode);
// 设置新库位
applicationOutMinById.setPlaceId(placeId);
// 修改子订单
result += depositoryRecordMapper.updateApplicationOutRecordMin(applicationOutMinById);
String redisMainRecordKey = "record:"+record.getId(); // 设置redis中主订单键值
// 获取redis中主订单的所有子订单
String minRecordList = (String) redisTemplate.opsForHash().get(redisMainRecordKey, "minRecord");
// 获取所有子订单键值
String[] split = minRecordList.replace("[", "").replace("]", "").split(",");
int pass = 1; // 设置主订单最终状态
for (int i = 0; i < split.length; i++) {
// 获取所有子订单状态
String state = (String) redisTemplate.opsForHash().get(split[i], "state");
if("1".equals(state)){
// 如果有子订单未完成
pass = 3; // 设置主订单状态为处理中
break;
}
}
if(pass == 1){ // 如果最终状态为完成
Map<String,Object> map = new HashMap<>();
map.put("pass",pass);
map.put("id",record.getId());
// 修改状态为完成
depositoryRecordMapper.updateApplicationOutRecord(map);
}
// 如果是库存转移订单
Map<String,Object> map = new HashMap<>();
if (record.getIstransfer() == 1) {
map.put("quantity", record.getQuantity().toString());
map.put("applicantId", record.getApplicantId());
map.put("transferId", record.getTransferId());
transferMaterial(map);
}
}else{
}
return result;
}
/**
* 转移申请
*
@ -369,7 +558,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
*/
@Override
@Transactional
public Integer transferApply(Map<String, Object> map,UserByPort userByPort) {
public Integer transferApply(Map<String, Object> map, UserByPort userByPort) {
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Double quantity = Double.parseDouble((String) map.get("quantity"));
Material material = materialMapper.findMaterialById(mid);
@ -383,12 +572,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("fromId", material.getDepositoryId());
String fromPlaceId = (String) map.get("fromPlaceId");
String toPlaceId = (String) map.get("placeId");
if("".equals(fromPlaceId) || "0".equals(fromPlaceId)){
map.put("fromPlaceId",0);
if ("".equals(fromPlaceId) || "0".equals(fromPlaceId)) {
map.put("fromPlaceId", 0);
}
map.put("toPlaceId",toPlaceId) ;
if("".equals(toPlaceId) || "0".equals(toPlaceId)){
map.put("toPlaceId",0);
map.put("toPlaceId", toPlaceId);
if ("".equals(toPlaceId) || "0".equals(toPlaceId)) {
map.put("toPlaceId", 0);
}
//清除主键
// depositoryRecordMapper.insertApplicationInRecord(map);
@ -397,10 +586,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("transferId", transferRecordByCondition.getId());
Depository depositoryRecordById = depositoryMapper.findDepositoryRecordById(material.getDepositoryId());
Administration company = PageController.getCompany(userByPort.getMaindeparment());
map.put("code", createCode(depositoryRecordById.getDname(), "outOrderNumber","out",company.getName()));
map.put("code", createCode(depositoryRecordById.getDname(), "outOrderNumber", "out", company.getName()));
String placeId = (String) map.get("placeId");
if("".equals(placeId)){
map.put("placeId",0);
if ("".equals(placeId)) {
map.put("placeId", 0);
}
//清除主键
return depositoryRecordMapper.insertApplicationOutRecord(map);
@ -437,92 +626,69 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} else {
map.put("state", "部门负责人审核未通过");
}
}
else {
} else {
String simpleTime = DateUtil.getSimpleTime(new Date());
map.put("depositoryManagerTime", DateUtil.DateTimeToTimeStamp(simpleTime));
map.put("depositoryManager", userid);
map.put("depositoryId", record.getDepositoryId());
// 获取主单下的子单
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(record.getId());
for (int i = 0; i < applicationOutRecordMinByParent.size(); i++) {
}
// map.put("mid", record.getMid());
// Material material = materialMapper.findMaterialById(record.getMid());
Integer depositoryManagerPass = (Integer) map.get("depositoryManagerPass");
if (depositoryManagerPass == 1) {
/*boolean flag = true;
Integer istransfer = record.getIstransfer();
Integer placeId = record.getPlaceId();
if(istransfer == 1){
TransferRecord transferRecordById = transferRecordMapper.findTransferRecordById(record.getTransferId());
placeId = transferRecordById.getFromPlaceId();// 获取转出库位
}
MaterialAndPlace placeAndMaterialByMidAndPid = null;
if(placeId != 0){
Map<String,Object> params = new HashMap<>();
params.put("mid",material.getId());
params.put("pid",placeId);
// 获取当前物料所存放库位的数量
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(params);
if(placeAndMaterialByMidAndPid.getQuantity() < record.getQuantity()){
// 如果当前库位数量不足
flag = false;
}
}else{
Map<String,Object> params = new HashMap<>();
params.put("mid",material.getId());
params.put("pid",0);
// 获取当前物料在默认库位中的数量
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(params);
if(placeAndMaterialByMidAndPid.getQuantity() < record.getQuantity()){
// 如果当前库位数量不足
flag = false;
// 如果审核通过
// 获取主单下的所有子单
StringBuilder minRecordByMain = new StringBuilder("[]");
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(record.getId());
for (int i = 0; i < applicationOutRecordMinByParent.size(); i++) {
// 获取子单信息
ApplicationOutRecordMin applicationOutRecordMin = applicationOutRecordMinByParent.get(i);
//设置子订单在redis中的主键
String minRecordKey = "minRecord:" + applicationOutRecordMin.getId();
minRecordByMain.insert(1, minRecordKey + ","); // 将子订单主键插入到主订单的子订单列表
// 设置当前子订单对应仓库管理员记录
StringBuilder minRecordManage = new StringBuilder();
// 将要存储到redis中的子订单信息
Map<String, Object> minRecord = new HashMap<>();
minRecord.put("parentId", record.getId().toString()); // 当前子订单主订单
minRecord.put("state", "1"); // 当前子订单状态 1待处理2处理
// 获取对应的物料编号
Integer mid = applicationOutRecordMin.getMid();
// 获取物料信息
Material materialById = materialMapper.findMaterialById(mid);
// 获取该物料所处仓库的仓库管理员
List<Integer> userIdByDid = new ArrayList<>();
userIdByDid = roleService.findUserIdByDid(materialById.getDepositoryId());
for (int j = 0; j < userIdByDid.size(); j++) {
// 仓库管理员订单信息
Map<String, Object> userRecord = new HashMap<>();
// 用户当前子订单
String userMinRecord = (String) redisTemplate.opsForHash().get("user:" + userIdByDid.get(j), "minRecord");
if (userMinRecord == null) { // 如果当前用户没有子订单
userRecord.put("minRecord", "[" + minRecordKey + "]"); // 插入一条子订单
} else { // 如果当前用户已经有子订单
StringBuilder minRecordList = new StringBuilder(userMinRecord); // 转为stringbuilder类型
minRecordList.insert(1, minRecordKey + ",");// 将当前子订单插入头部
userRecord.put("minRecord", minRecordList.toString());
}
// 更新redis中用户记录
redisTemplate.opsForHash().putAll("user:" + userIdByDid.get(j), userRecord);
minRecordManage.append(userIdByDid.get(j)).append(",");
}
minRecord.put("manager", minRecordManage.toString());
// 添加子订单到redis中
redisTemplate.opsForHash().putAll(minRecordKey, minRecord);
}
if (material.getQuantity() >= record.getQuantity() && flag) {
// 当前出库金额
Double sum = material.getPrice() * record.getQuantity();
material.setAmounts(material.getAmounts() - sum);
material.setQuantity(material.getQuantity() - record.getQuantity());
material.setNumberOfTemporary(material.getNumberOfTemporary() - record.getQuantity());
materialMapper.updateMaterial(material);
if(placeAndMaterialByMidAndPid != null){
// 修改当前库位存放物料的数量
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - record.getQuantity());
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
}
// 修改库位数量
Place placeById = placeMapper.findPlaceById(placeId);
placeById.setQuantity(placeById.getQuantity() - record.getQuantity());
placeMapper.UpdatePlace(placeById);
if (record.getIstransfer() == 1) {
map.put("quantity", record.getQuantity().toString());
map.put("applicantId", record.getApplicantId());
map.put("transferId", record.getTransferId());
transferMaterial(map);
}
} else {
map.put("state", "未出库");
map.put("depositoryManagerMessage", "当前仓位库存量不足");
Map<String, Object> update = new HashMap<>();
// update.put("id", material.getId());
update.put("numberOfTemporary", 0);
materialMapper.updateMaterial(update);
depositoryRecordMapper.updateApplicationOutRecord(map);
return -1;
}
*/
map.put("state", "出库中");
// 将主订单插入到redis中
redisTemplate.opsForHash().put("record:" + record.getId(), "minRecord", minRecordByMain.toString());
map.put("state", "仓储中心负责人审核通过");
} else {
map.put("pass", 2);
map.put("state", "仓储中心负责人审核未通过");
}
}
map.put("id",id);
map.put("id", id);
return depositoryRecordMapper.updateApplicationOutRecord(map);
}
@ -543,9 +709,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<Material> materiallist = materialMapper.findInventory(param);
if (materiallist.size() > 0) {
// 如果在该仓库
map.put("price",material.getPrice().toString());
map.put("price", material.getPrice().toString());
map.put("depositoryId", transferRecor.getToId());
map.put("placeId",transferRecor.getToPlaceId());
map.put("placeId", transferRecor.getToPlaceId());
applicationInPlace(map);
map.put("mid", materiallist.get(0).getId());
} else {
@ -567,34 +733,34 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
materialMapper.insertMaterial(insert);
// 查询该记录
Map<String,Object> temp = new HashMap<>();
temp.put("code",materialById.getCode());
temp.put("depositoryId",transferRecor.getToId());
temp.put("mname",materialById.getMname());
Map<String, Object> temp = new HashMap<>();
temp.put("code", materialById.getCode());
temp.put("depositoryId", transferRecor.getToId());
temp.put("mname", materialById.getMname());
List<Material> inventoryList = materialMapper.findInventory(temp);
// 获取该库存记录
Material inventory = inventoryList.get(0);
Map<String,Object> fromPlaceTemp = new HashMap<>();
Map<String,Object> toPlaceTemp = new HashMap<>();
Map<String, Object> fromPlaceTemp = new HashMap<>();
Map<String, Object> toPlaceTemp = new HashMap<>();
// 转入库位
Place toPlace = placeMapper.findPlaceById(transferRecor.getToPlaceId());
toPlace.setQuantity(toPlace.getQuantity() + quantity);
placeMapper.UpdatePlace(toPlace); // 修改转入库位额度
toPlaceTemp.put("mid",materialById.getId());
toPlaceTemp.put("pid",toPlace.getId());
toPlaceTemp.put("quantity",quantity);
toPlaceTemp.put("mid", materialById.getId());
toPlaceTemp.put("pid", toPlace.getId());
toPlaceTemp.put("quantity", quantity);
// 获取转入物料具体所在库位
MaterialAndPlace toMaterialAndPlace = placeMapper.findPlaceAndMaterialByMidAndPid(toPlaceTemp);
if(toMaterialAndPlace == null){
if (toMaterialAndPlace == null) {
placeMapper.addMaterialOnPlace(toPlaceTemp);
}
// 转出库位
Place fromPlace = placeMapper.findPlaceById(transferRecor.getFromPlaceId());
fromPlace.setQuantity(fromPlace.getQuantity() - quantity);
placeMapper.UpdatePlace(fromPlace); // 修改转出库位额度
fromPlaceTemp.put("mid",materialById.getId());
fromPlaceTemp.put("pid",toPlace.getId());
fromPlaceTemp.put("mid", materialById.getId());
fromPlaceTemp.put("pid", toPlace.getId());
// 获取转出物料具体所在库位
MaterialAndPlace fromMaterialAndPlace = placeMapper.findPlaceAndMaterialByMidAndPid(fromPlaceTemp);
fromMaterialAndPlace.setQuantity(fromMaterialAndPlace.getQuantity() - quantity);
@ -1178,7 +1344,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
JSONObject paramObject = JSONObject.parseObject(jsonString);
String post = null;
try {
post = HttpUtils.send(url, paramObject, HTTP.UTF_8);
post = HttpUtils.send(url, paramObject, StandardCharsets.UTF_8.toString());
} catch (IOException e) {
e.printStackTrace();
}
@ -1194,7 +1360,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @param depositoryName
* @return
*/
private String createCode(String depositoryName, String key,String type,String mainDeparmentName) {
private String createCode(String depositoryName, String key, String type, String mainDeparmentName) {
RLock lock = redissonClient.getLock(key);
// 入库单号(公司简称+仓库简称+年月日+数字(位数设置>=9))
String code = "GK";
@ -1210,10 +1376,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
redisTemplate.boundValueOps(key).set(String.valueOf(newNumber), DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS);
lock.unlock();
orderNumber = String.format("%09d", ObjectFormatUtil.toInteger(orderNumber));
if("in".equals(type)){
if ("in".equals(type)) {
code = code + depositoryName + nowTime + orderNumber;
}
else if("out".equals(type)){
} else if ("out".equals(type)) {
mainDeparmentName = WordUtil.getPinYinHeadChar(mainDeparmentName);
code = code + mainDeparmentName + nowTime + orderNumber;
}

2
src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

@ -322,7 +322,7 @@ public class ExcelServiceImpl implements ExcelService {
placeById.setQuantity(placeById.getQuantity() + ObjectFormatUtil.toInteger(excelVos.get(i).getQuantity()));
placeService.UpdatePlace(placeById);
// 添加库位与物料的映射
param.put("mid",materialByCode.getId());
param.put("mid",insert.get("id"));
param.put("pid",0);
param.put("quantity",ObjectFormatUtil.toInteger(excelVos.get(i).getQuantity()));
placeService.addMaterialOnPlace(param);

14
src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java

@ -220,5 +220,19 @@ public class PlaceServiceImpl implements PlaceService {
return placeMapper.addMaterialOnPlace(map);
}
/**
* 获取当前物料在当前库位的数量
* @param mid
* @param pid
* @return
*/
@Override
public Integer findQuantityByMidAndPid(Integer mid, Integer pid) {
Map<String,Object> map = new HashMap<>();
map.put("pid",pid);
map.put("mid",mid);
return placeMapper.findQuantityByMidAndPid(map);
}
}

5
src/main/java/com/dreamchaser/depository_manage/service/impl/UserServiceImpl.java

@ -8,6 +8,7 @@ import com.dreamchaser.depository_manage.pojo.UserP;
import com.dreamchaser.depository_manage.service.UserService;
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.thymeleaf.expression.Ids;
@ -27,6 +28,9 @@ public class UserServiceImpl implements UserService {
@Autowired
DepositoryMapper depositoryMapper;
@Autowired
RedisTemplate<Object,Object> redisTemplate;
@Override
public Integer findCount() {
return userMapper.findCount();
@ -178,4 +182,5 @@ public class UserServiceImpl implements UserService {
}
}

37
src/main/resources/templates/pages/application/application-out.html

@ -293,7 +293,7 @@
success: function (d) {
var d = d.data;
if(d == null){
layer.msg("没有该编码,请确认是否输入正确");
layer.msg("仓库中暂无该物料");
materialName.value = "";
materialId.value = "";
obj.value = "";
@ -400,8 +400,9 @@
var id = obj.id.split("quantity")[1];
var mcode = $("#code"+id).val(); // 获取到当前输入的物料编码
if(mcode === "" || mcode ===undefined || mcode === null){
layer.msg("请输入物料的正确编码!");
$("#quantity"+id).val("")
layer.msg("请输入物料的正确编码!",{icon:1,time:500},function () {
$("#quantity"+id).val("")
});
}else{
var req = {};
req.code = mcode;
@ -415,20 +416,22 @@
success:function (res) {
var flag = res.data;
if(!flag){ // 如果当前数目不合适
layer.msg("当前物料数量不足");
$("#quantity"+id).val("");
// 获取对应元素
var parent = obj.parentNode.parentNode.parentNode;
var children = parent.childNodes[5];
var codeChildren = parent.childNodes[7];
var materialItem = children.childNodes[3].childNodes[1].childNodes;
var materialName = materialItem[1];
var materialId = materialName.parentNode.parentNode.childNodes[3];
var codeItem = codeChildren.childNodes[3].childNodes;
var codeValue = codeItem[1];
materialName.value = "";
materialId.value = "";
codeValue.value = "";
layer.msg("当前物料数量不足",{icon:1,time:500},function () {
$("#quantity"+id).val("");
// 获取对应元素
var parent = obj.parentNode.parentNode.parentNode;
var children = parent.childNodes[5];
var codeChildren = parent.childNodes[7];
var materialItem = children.childNodes[3].childNodes[1].childNodes;
var materialName = materialItem[1];
var materialId = materialName.parentNode.parentNode.childNodes[3];
var codeItem = codeChildren.childNodes[3].childNodes;
var codeValue = codeItem[1];
materialName.value = "";
materialId.value = "";
codeValue.value = "";
});
}
}
});

121
src/main/resources/templates/pages/application/application-out_min.html

@ -0,0 +1,121 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
<link rel="stylesheet" href="/static/css/public.css" media="all">
<link rel="stylesheet" href="/static/js/lay-module/step-lay/step.css" media="all">
</head>
<body>
<div class="layuimini-container">
<div class="layuimini-main">
<input id="depositoryId" type="text" th:value="${depositoryId}" style="display: none">
<input id="state" type="text" th:value="${state}" style="display: none">
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
</div>
</div>
<script type="text/html" id="currentTableBar">
{{# if(d.state == "进行中"){ }}
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="scanQrCode">扫码</a>
{{# } }}
</script>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
layui.use(['form', 'table','laydate'], function () {
var $ = layui.jquery,
form = layui.form,
table = layui.table,
laydate = layui.laydate;
var depositoryId = $("#depositoryId").val();
// 0未完成1已完成
var state = $("#state").val();
table.render({
elem: "#currentTableId",
url: '/depositoryRecord/ApplicationOutMinByDid',
parseData: function (res) { //res 即为原始返回的数据
return {
"status": res.status, //解析接口状态
"message": res.statusInfo.message, //解析提示文本
"count": res.count, //解析数据长度
"data": res.data //解析数据列表
};
},
request: {
pageName: 'page', //页码的参数名称,默认:page
limitName: 'size' //每页数据量的参数名,默认:limit
},
where: {
"depositoryId":depositoryId,
"state":state
},
response: {
statusName: 'status' //规定数据状态的字段名称,默认:code
,statusCode: 200 //规定成功的状态码,默认:0
,msgName: 'message' //规定状态信息的字段名称,默认:msg
,countName: 'count' //规定数据总数的字段名称,默认:count
,dataName: 'data' //规定数据列表的字段名称,默认:data
},
toolbar: '#toolbarDemo',
//这里layui和thymeleaf冲突了,要加个空格
cols: [ [
{title: '操作', width: 100, toolbar: '#currentTableBar', align: "center"},
{field: 'id', width: 100, title: '提交编号', sort: true},
{field: 'code', width: 200, title: '提交编码', sort: true},
{field: 'mname', width: 120, title: '物料名称'},
{field: 'mcode', width: 120, title: '物料编码'},
{field: 'depositoryName', width: 120, title: '仓库名称'},
{field: 'pcode', width: 120, title: '库位编码'},
{field: 'quantity', width: 80, title: '数量', sort: true},
{field: 'applicantName', width: 150, title: '申请人'},
{field: 'applicantTime', width: 200, title: '申请时间', sort: true},
{field: 'applyRemark', width: 200, title: '备注'},
{field: 'state', width: 200, title: '状态'}
]],
limits: [10, 15, 20, 25, 50],
limit: 10,
page: true,
skin: 'line',
done:function () {
$("[data-field='id']").css('display','none');
}
});
table.on('tool(currentTableFilter)', function (obj) {
let data = obj.data;
if (obj.event === 'scanQrCode') {
layer.open({
type: 2,
title: '扫码',
skin: 'layui-layer-rim',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['100%', '100%'],
move : '.layui-layer-title',
fixed:false,
content: '/scanQrCodeByOut?id='+data.id,
end:function () {
table.reload('currentTableId', {
url: '/depositoryRecord/ApplicationOutMinByDid',
page: {
curr: 1
}
}, 'data');
}
})
}
})
});
</script>
</body>
</html>

29
src/main/resources/templates/pages/application/application-review.html

@ -54,6 +54,7 @@
<tr>
<td>状态</td>
<td id="state" th:text="${record.getState()}">状态</td>
<td id="pass" th:text="${record.getPass()}" style="display:none;"></td>
</tr>
<tr>
<td>申请人</td>
@ -81,8 +82,8 @@
<td id="departmentheadTime" th:text="${record.getDepartmentheadTime().equals('1970-01-01 08:00:00')?'':record.getDepartmentheadTime()}">1970-01-01 08:00:00</td>
</tr>
<tr id="depositoryManagerNameT" style="display: none">
<td>库管理员</td>
<td id="depositoryManagerName" th:text="${record.getDepositoryManagerName()}">库管理员</td>
<td>储负责人</td>
<td id="depositoryManagerName" th:text="${record.getDepositoryManagerName()}">储负责人</td>
</tr>
</tbody>
</table>
@ -159,6 +160,7 @@
step = layui.step;
var state=$("#state").text();
var pass = $("#pass").text();
//当前处于的状态
var position=0,states={},number = 1;
if (state === "待部门负责人审核" || state === "部门负责人审核未通过") {
@ -166,9 +168,21 @@
states = [ {title: state}];
number = 2;
} else {
// {title: "提交申请"},
states = [ {title: state}];
number = 3;
if(state === "待仓储中心负责人审核"|| state === "仓储中心负责人审核未通过"){
states = [ {title: state}];
number = 3;
}else{
if(pass === 1 || pass === "1"){
number = 4;
states = [{title:"已出库"}]
}else if(pass === 3 || pass === "3"){
number = 4;
states = [{title:"出库中"}]
}else if(pass === 2 || pass === "2"){
number = 4;
states = [{title:"未出库"}]
}
}
}
step.render({
elem: '#stepForm',
@ -199,7 +213,7 @@
}
data.departmentheadMessage=$("#departmentheadMessageF").val();
send(data);
}
};
check=function(pass) {
let data={};
data.id=$("#id").text();
@ -210,9 +224,8 @@
}
data.depositoryManagerMessage=$("#depositoryManagerMessageF").val();
send(data);
}
};
function send(req) {
console.log(JSON.stringify(req));
$.ajax({
url:"/depositoryRecord/review",
type:'put',

13
src/main/resources/templates/pages/application/application_multi.html

@ -68,6 +68,7 @@
{field: 'version', width: '10%', title: '规格型号'},
{field: 'code',width: 200,title: '存货编码',sort: true},
{field: 'depositoryName', width: '12%', title: '仓库名称'},
{field: 'placeCode', width: '12%', title: '库位编码'},
{field: 'quantity', width: '10%', title: '数量',edit:'quantity'},
{field: 'price', width: '10%', title: '单价',edit:'price'},
{field: 'depositoryId', width: '10%', title: '仓库编号',edit:'quantity'},
@ -107,15 +108,19 @@
req.quantitys = [];
req.applyRemarks = [];
req.prices = [];
req.placeCodes = [];
for (i = 0, len = data.length; i < len; i++) {
req.mids[i] = data[i].mid;
req.depositoryIds[i] = data[i].depositoryId;
req.quantitys[i] = data[i].quantity;
req.applyRemarks[i] = data[i].applyRemark;
req.prices[i] = data[i].price;
req.placeCodes[i] = data[i].placeCode;
}
if(obj.event==='delete'){
if(req.mids > 0) {
console.log(req)
if(req.mids.length > 0) {
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
$.ajax({
url: "/depositoryRecord/deleteApplicationToRedis",
@ -186,7 +191,11 @@
if (d.status >= 300) {
layer.msg(d.statusInfo.message);//失败的表情
return;
} else {
}else if(d.status === 1234){
layer.msg(d.data)
return
}
else {
layer.msg("申请成功!", {
icon: 6,//成功的表情
time: 1000

28
src/main/resources/templates/pages/application/form-step-look_back.html

@ -53,6 +53,7 @@
<tr>
<td>状态</td>
<td id="state" th:text="${record.getState()}">2016-11-28</td>
<td id="pass" th:text="${record.getPass()}" style="display:none;"></td>
</tr>
<tr>
<td>申请人</td>
@ -80,15 +81,15 @@
<td id="departmentheadTime" th:text="${record.getDepartmentheadTime().equals('1970-01-01 08:00:00')?'':record.getDepartmentheadTime()}">2016-11-28</td>
</tr>
<tr id="depositoryManagerNameT" style="display: none">
<td>库管理员</td>
<td id="depositoryManagerName" th:text="${record.getDepositoryManagerName()}">2016-11-28</td>
<td>储负责人</td>
<td id="depositoryManagerName" th:text="${record.getDepositoryManagerName()}">仓储负责人</td>
</tr>
<tr id="depositoryManagerNameMessageT" style="display: none">
<td>库管理员备注</td>
<td>储负责人备注</td>
<td id="depositoryManagerNameMessage" th:text="${record.getDepositoryManagerMessage()}">2016-11-28</td>
</tr>
<tr id="depositoryManagerNameTimeT" style="display: none">
<td>库管理员审核时间</td>
<td>储负责人审核时间</td>
<td id="depositoryManagerNameTime" th:text="${record.getDepositoryManagerTime().equals('1970-01-01 08:00:00')?'':record.getDepositoryManagerTime()}">2016-11-28</td>
</tr>
@ -121,6 +122,7 @@
var state=$("#state").text();
var pass=$("#pass").text();
//当前处于的状态
var position=0,states={},number = 1;
@ -128,8 +130,22 @@
states = [ {title: state}];
number = 2;
} else {
states = [ {title: state}];
number = 3;
if(state === "待仓储中心负责人审核"|| state === "仓储中心负责人审核未通过"){
states = [ {title: state}];
number = 3;
}else{
if(pass === 1 || pass === "1"){
number = 4;
states = [{title:"已出库"}]
}else if(pass === 3 || pass === "3"){
number = 4;
states = [{title:"出库中"}]
}else if(pass === 2 || pass === "2"){
number = 4;
states = [{title:"未出库"}]
}
}
}
step.render({
elem: '#stepForm',

128
src/main/resources/templates/pages/application/my-task.html

@ -28,13 +28,27 @@
<fieldset class="layui-elem-field layui-field-title">
<legend>未完成任务</legend>
</fieldset>
<fieldset class="layui-elem-field layui-field-title">
<legend>审核任务</legend>
</fieldset>
<ul id="LAY_floor1" class="flow-default" style="width: 100%"></ul>
<fieldset class="layui-elem-field layui-field-title">
<legend>出库任务</legend>
</fieldset>
<ul id="LAY_floor3" class="flow-default" style="width: 100%"></ul>
</div>
<div class="layui-bg-gray" style="padding: 10px;">
<fieldset class="layui-elem-field layui-field-title">
<legend>已完成任务</legend>
</fieldset>
<fieldset class="layui-elem-field layui-field-title">
<legend>审核任务</legend>
</fieldset>
<ul id="LAY_floor2" class="flow-default" style="width: 100%"></ul>
<fieldset class="layui-elem-field layui-field-title">
<legend>出库任务</legend>
</fieldset>
<ul id="LAY_floor4" class="flow-default" style="width: 100%"></ul>
</div>
@ -51,6 +65,13 @@
//先声明
function openDetail2(data) {
};
//先声明
function openDetail3(data) {
};
//先声明
function openDetail4(data) {
};
layui.use(['flow', 'layer', 'table', 'util'], function () {
var $ = layui.jquery,
layer = layui.layer,
@ -77,7 +98,7 @@
}
lis.push('<li style="width:'+ Width +';float:left;"><div class="layui-card my-shadow my-card flow1" onclick="openDetail1('
+result[i].id+')"><div class="layui-card-header"><h2>'
+result[i].applicantName+'的')
+result[i].applicantName+'的');
lis.push('出库请求</h2></div>');
lis.push('<div class="layui-col-md4 my-time" style="margin-left: 15px; color: #999;font-size: 12px;">'
+result[i].applicantTime+'</div></div></li>');
@ -124,7 +145,73 @@
});
}
});
flow.load({
elem: '#LAY_floor3' //流加载容器
,scrollElem: '#LAY_floor3' //滚动条所在元素,一般不用填,此处只是演示需要。
,isAuto:false
,done: function(page, next){ //执行下一页的回调
let lis = [];
let result;
$.get('/depositoryRecord/myTashForScanQrCode?page='+page+'&size='+size+'&isDone=0', function(res){
var Width = "25%";
result=res.data;
const keys = Object.keys(result); // 获取map中所有的键
lis.push("<div class='clearfix'>");
for (let i = 0; i < keys.length; i++) {
if(isMobile()){
Width = "50%";
}
lis.push('<li style="width:'+ Width +';float:left;"><div class="layui-card my-shadow my-card flow1" onclick="openDetail3('
+result[keys[i]][0].depositoryId+')" ><div class="layui-card-header"><h2>'
+result[keys[i]][0].depositoryName+'</h2></div>')
lis.push('<div class="layui-col-md4 my-time" style="margin-left: 15px; color: #999;font-size: 12px;">'
+result[keys[i]][0].applicantTime+'</div></div></li>');
}
lis.push("</div>")
pre2+=result.length;
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(''), pre2 < res.count);
});
}
});
flow.load({
elem: '#LAY_floor4' //流加载容器
,scrollElem: '#LAY_floor4' //滚动条所在元素,一般不用填,此处只是演示需要。
,isAuto:false
,done: function(page, next){ //执行下一页的回调
let lis = [];
let result;
$.get('/depositoryRecord/myTashForScanQrCode?page='+page+'&size='+size+'&isDone=1', function(res){
var Width = "25%";
result=res.data;
const keys = Object.keys(result); // 获取map中所有的键
lis.push("<div class='clearfix'>");
for (let i = 0; i < keys.length; i++) {
if(isMobile()){
Width = "50%";
}
lis.push('<li style="width:'+ Width +';float:left;"><div class="layui-card my-shadow my-card flow1" onclick="openDetail4('
+result[keys[i]][0].depositoryId+')" ><div class="layui-card-header"><h2>'
+result[keys[i]][0].depositoryName+'</h2></div>')
lis.push('<div class="layui-col-md4 my-time" style="margin-left: 15px; color: #999;font-size: 12px;">'
+result[keys[i]][0].applicantTime+'</div></div></li>');
}
lis.push("</div>")
pre2+=result.length;
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(''), pre2 < res.count);
});
}
});
openDetail1 = function (item) {
var index = layer.open({
title: '请求详情',
@ -142,7 +229,7 @@
$(window).on("resize", function () {
layer.full(index);
});
}
};
openDetail2 = function (item) {
var index = layer.open({
title: '请求详情',
@ -159,7 +246,42 @@
$(window).on("resize", function () {
layer.full(index);
});
}
};
openDetail3 = function (item) {
var index = layer.open({
title: '请求详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/ApplicationOutMinByDid?depositoryId='+item+"&state=0",
end:function () {
location.reload()
}
});
$(window).on("resize", function () {
layer.full(index);
});
};
openDetail4 = function (item) {
var index = layer.open({
title: '请求详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/ApplicationOutMinByDid?depositoryId='+item+"&state=1",
end:function () {
location.reload()
}
});
$(window).on("resize", function () {
layer.full(index);
});
};
//定义一个函数判断是手机端还是pc端
function isMobile(){

5
src/main/resources/templates/pages/depository/table-in.html

@ -142,7 +142,10 @@
limits: [10, 15, 20, 25, 50],
limit: 10,
page: true,
skin: 'line'
skin: 'line',
done:function () {
$("[data-field='id']").css('display','none');
}
});
// 监听搜索操作

11
src/main/resources/templates/pages/depository/table-out.html

@ -135,10 +135,19 @@
{field: 'quantity', width: 80, title: '数量', sort: true},
{field: 'price', title: '金额', minWidth: 80, sort: true},
{field: 'state', width: 150, title: '流程状态'},
{
field: 'pass', title: '是否完成出库', minWidth: 120, templet: function (d) {
if (d.pass == 1){
return "是";
}else{
return "否";
}
}
},
{field: 'applicantName', width: 150, title: '申请人'},
{field: 'applicantTime', width: 200, title: '申请时间', sort: true},
{
field: 'istransfer', title: '是否为转移申请', minWidth: 80, templet: function (d) {
field: 'istransfer', title: '是否为转移申请', minWidth: 120, templet: function (d) {
if (d.istransfer == 1){
return "是";
}else if(d.istransfer == 2){

2
src/main/resources/templates/pages/depository/table-stock.html

@ -179,9 +179,11 @@
var req = {};
req.mids = [];
req.depositoryIds = [];
req.placeCodes = [];
for (i = 0, len = data.length; i < len; i++) {
req.mids[i] = data[i].id;
req.depositoryIds[i] = data[i].depositoryId;
req.placeCodes[i] = data[i].placeCode;
}
if(req.mids.length > 0) {
$.ajax({

9
src/main/resources/templates/pages/material/material-out.html

@ -46,6 +46,12 @@
<input type="text" name="mname" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">存货编码</label>
<div class="layui-input-inline">
<input type="text" name="code" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">状态</label>
<div class="layui-input-inline">
@ -198,6 +204,9 @@
if(data.state != ''){
req.state = data.state;
}
if(data.code != ''){
req.code = data.code
}
//执行搜索重载
table.reload('currentTableId', {

1
src/main/resources/templates/pages/material/selectType.html

@ -36,7 +36,6 @@
contentType: "application/json;charset=utf-8",
success: function (d) {
var data2 = d.data
console.log(data2)
test.reload({
data:data2
});

1
src/main/resources/templates/pages/place/place_edit.html

@ -92,7 +92,6 @@
layer = layui.layer;
var depositoryId = $("#depositoryId").val();
console.log(depositoryId);
form.on('submit(formStep)', function (data) {
var req = data.field;
req.type = "one";

1
src/main/resources/templates/pages/post/postRole_add.html

@ -96,7 +96,6 @@
success: function (data) {
layer.close(this.layerIndex);
if (data.status >= 300) {
console.log(data)
layer.msg(data.statusInfo.message,{
icon: 7,
time: 200

329
src/main/resources/templates/pages/scanQrCode/scanQrCodeOut.html

@ -47,6 +47,10 @@
</head>
<body>
<div id="app">
<input id="id" style="display: none" th:value="${record.getId()}">
<input id="mcode" style="display: none" th:value="${materialById.getCode()}">
<input id="depositoryId" style="display: none" th:value="${record.getDepositoryId()}">
<input id="quantity" style="display: none" th:value="${record.getQuantity()}">
<qrcode-stream :camera="camera" @decode="onDecode" @init="onInit" :track="paintBoundingBox">
<div v-if="validationPending" class="validation-pending">
Long validation in progress...
@ -56,7 +60,10 @@
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
Vue.use(httpVueLoader);
let id = layui.$("#id").val();
let mcode = layui.$("#mcode").val();
let depositoryId = layui.$("#depositoryId").val();
let quantity = layui.$("#quantity").val();
var vue = new Vue({
data() {
return {
@ -64,7 +71,7 @@
camera: 'auto',
result: '',
error: '',
materialList: [],
material: null,
depository: null,
place: null
@ -83,142 +90,139 @@
let parse = JSON.parse(result);
vue.turnCameraOff(); // 暂停扫描
if (parse.did !== undefined) {
// 如果扫描的是仓库二维码
//如果扫描的为仓库
this.depository = parse;// 将扫描结果保存到vue中
params.depository = this.depository;
params.place = this.place;
params.materialList = this.materialList;
if (this.materialList.length > 0) {
// 如果有物料
this.temporaryScanValue(params); // 将数据暂存至redis中
this.chooseInOrOut(); // 弹出选择框
} else {
// 如果没有
layer.confirm("暂未选择物料,是否继续扫描", {
btn:["继续","取消"]
if(this.material == null){
// 如果还没有扫描物料
layer.confirm("请扫描物料", {
btn:["扫描","取消"]
},function () { // 继续
vue.turnCameraOn(); // 继续扫描
layer.close(layer.index); // 关闭弹窗
},function () { // 取消
vue.temporaryScanValue(params); // 将数据暂存
vue.chooseInOrOut(); // 弹出选择框
// 将vue中暂存的数据置为空
this.depository = null;
this.place = null;
this.material = null;
})
}
}
else if (parse.pid !== undefined) {
// 如果扫描的是库位二维码
this.place = parse; // 将扫描结果保存到vue中
params.depository = this.depository;
params.place = this.place;
params.materialList = this.materialList;
if (this.materialList.length > 0) {
// 如果有物料
this.temporaryScanValue(params); // 将数据暂存至redis中
this.chooseInOrOut(); // 弹出选择框
} else {
// 如果没有
layer.confirm("当前并未扫描物料,是否继续扫描",
{btn:["继续","取消"]},
function () { // 继续扫描
vue.turnCameraOn(); // 继续扫描
layer.close(layer.index); // 关闭弹窗
},
function () {
vue.temporaryScanValue(params); // 将数据暂存
vue.chooseInOrOut(); // 弹出选择框
}
)
else{
// 如果已经扫描物料
if(depositoryId !== parse.did && Number(depositoryId) !== parse.did && depositoryId !== parse.did.toString()){
// 如果当前仓库不是订单对应仓库
this.depository = null;
this.place = null;
layer.msg("出库仓库不正确,请重新扫描");
this.turnCameraOn()
}else{
var req = {};
req.id = id;
vue.isOutTrue(req);
}
}
}
else if (parse.mid !== undefined) {
// 如果扫描的是物料二维码
this.materialList.push(parse);
layer.confirm("是否继续扫描",
{
btn: ["继续", "取消"]
},
function () { // 继续扫描物料
else if (parse.pid !== undefined){
// 如果扫描的为库位
this.place = parse;// 将扫描结果保存到vue中
if(this.material == null){
// 如果还没有扫描物料
layer.confirm("请扫描物料", {
btn:["扫描","取消"]
},function () { // 继续
vue.turnCameraOn(); // 继续扫描
layer.close(layer.index); // 关闭弹窗
},
function () {
// 不扫描物料
params.materialList = vue.materialList;
params.depository = vue.depository;
params.place = vue.place;
vue.temporaryScanValue(params); // 将物料暂存
if (vue.depository !== '' || vue.place !== '') {
// 如果已经扫描了仓库或库位
// 弹出选择框
vue.chooseInOrOut();
},function () { // 取消
// 将vue中暂存的库位置为空
this.place = null;
})
}else{
if(depositoryId !== parse.depositoryId && Number(depositoryId) !== parse.depositoryId && depositoryId !== parse.depositoryId.toString()){
// 如果当前仓库不是订单对应仓库
this.depository = null;
this.place = null;
layer.msg("出库库位所在仓库不正确,请重新扫描");
this.turnCameraOn()
}else if(parse.mcodeList.indexOf(mcode) === -1){
// 如果当前库位不存在该物料
this.depository = null;
this.place = null;
layer.msg("出库库位不含该物料,请重新扫描");
this.turnCameraOn()
}
else{
var req = {};
req.placeId= this.place.pid;
req.id = id;
vue.isOutTrue(req);
}
}
}
else if (parse.mid !== undefined){
// 如果扫描的为物料
this.material = parse;// 将扫描结果保存到vue中
if(mcode !== this.material.code && Number(mcode) !== this.material.code && mcode !== this.material.code.toString()){
this.material = null;
layer.msg("出库物料不正确,请重新扫描");
this.turnCameraOn()
}
else {
if (this.depository !== null) { // 如果已经扫描仓库
let depository = this.depository;
if (depositoryId !== depository.did && Number(depositoryId) !== depository.did && depositoryId !== depository.did.toString()) {
// 如果扫描的仓库不是订单要求的仓库
layer.confirm("当前仓库不符合要求,请移步至正确仓库", {
btn: ["确定"]
}, function () {
// 将vue中仓库设为空
vue.depository = null;
layer.close(layer.index); // 关闭弹窗
})
} else {
// 如果是出库位置为默认库位
var req = {};
req.id = id;
// 弹出确定框
vue.isOutTrue(req);
}
else {
// 如果没有扫描仓库或库位
layer.confirm("暂未扫描仓库,是否继续该操作",
{
btn: ["继续", "取消"]
},
function () {// 继续
// 弹出选择框
vue.chooseInOrOut();
},
function () { // 取消当前操作
vue.turnCameraOn(); // 继续扫描
layer.close(layer.index); // 关闭弹窗
}
)
}
else if(this.place != null){
// 如果已经扫描库位
if(depositoryId !== this.place.depositoryId && Number(depositoryId) !== this.place.depositoryId && depositoryId !== this.place.depositoryId.toString()){
// 如果当前仓库不是订单对应仓库
this.depository = null;
this.place = null;
layer.msg("出库库位所在仓库不正确,请重新扫描");
this.turnCameraOn()
}else if(this.place.mcodeList.indexOf(mcode) === -1){
// 如果当前库位不存在该物料
this.depository = null;
this.place = null;
layer.msg("出库库位不含该物料,请重新扫描");
this.turnCameraOn()
}
else{
var req = {};
req.id = id;
req.placeId= this.place.pid;
// 弹出确定框
vue.isOutTrue(req);
}
}
)
}
},
/*layer.confirm("请选择入库|出库",{
btn:["入库","出库"]},
function () {
layer.open({
type: 2,
title: '入库',
skin: 'layui-layer-rim',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['100%', '100%'],
move : '.layui-layer-title',
fixed:false,
content: '/application_in_back?mid='+material.mid,
})
},function () {
let req = {};
req.code = material.code;
req.type = "out";
layui.$.ajax({
url: "/material/findMatrialByCode",
type: "get",
dataType: 'json',
data:(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
var d = d.data;
if(d !== null){
if(d == null) {
layer.msg("没有该编码,请确认是否输入正确");
}else{
layer.open({
type: 2,
title: '出库',
skin: 'layui-layer-rim',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['100%', '100%'],
move : '.layui-layer-title',
fixed:false,
content: '/application_out_back?code='+d.code+"&depositoryCode="+d.depositoryCode,
else {
layer.confirm("请扫描仓库或库位", {
btn: ["扫描", "取消"]
}, function () { // 继续
vue.turnCameraOn(); // 继续扫描
layer.close(layer.index); // 关闭弹窗
}, function () { // 取消
// 将vue中暂存的库位置为空
this.material = null;
})
}
}
}
})
}
)*/
},
async onInit(promise) {
try {
await promise.then(this.resetValidationState)
@ -277,55 +281,50 @@
data: JSON.stringify(params)
});
},
// 弹出入库|出库选择框
chooseInOrOut(){
layer.confirm("请选择入库|出库", {
btn: ["入库"]
},
function () { // 选择入库
layer.open({
type: 2,
title: '入库',
skin: 'layui-layer-rim',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['100%', '100%'],
move: '.layui-layer-title',
fixed: false,
content: '/application_in_scanQrCode',
end:function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
}
})
},
function () { // 选择出库
layui.$.ajax({ // 判断当前物料是否存在库存
url:"/material/IsMaterialExist",
type:"get",
dataType: 'json',
contentType: "application/json;charset=utf-8",
success:function (d) {
layer.open({
type: 2,
title: '出库',
skin: 'layui-layer-rim',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['100%', '100%'],
move: '.layui-layer-title',
fixed: false,
content: '/application_Out_scanQrCode',
end:function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
// 弹出出库确定弹出框
isOutTrue(req){
layer.confirm("确定出库?", {
btn: ["确定", "取消"]
}, function () { // 如果确定出库
layui.$.ajax({
url: "/depositoryRecord/isCheckOut",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (res) {
if (res.status === 200) {
// 如果出库成功
layer.msg("出库成功",
{icon:6,
time:500
}
})
}
});
, function () {
layer.close(layer.index);
});
layer.close(layer.index)
} else {
// 如果出库失败
layer.msg(res.statusInfo.message+",请重试");
vue.depository = null;
vue.material = null;
vue.place = null;
// 继续扫描
vue.turnCameraOn();
return
}
}
})
}, function () {
// 如果取消
vue.depository = null;
vue.material = null;
vue.place = null;
})
}
}
}).$mount('#app')
</script>

10
src/test/java/com/dreamchaser/depository_manage/Test.java

@ -27,13 +27,19 @@ import javax.swing.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
@SpringBootTest
@RunWith(SpringRunner.class)
public class Test {
@Autowired
RedisTemplate<String,String> redisTemplate;
@org.junit.Test
public void test1(){
System.out.println(DateUtil.TimeStampToDateTime(Long.valueOf("1664035200000")));
StringBuilder code = new StringBuilder("GKQGB20221013000000004");
int qgb = code.indexOf("QGB");
System.out.println(code.replace(qgb,qgb+"QGB".length(),"CS"));
}

75
target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -97,7 +97,7 @@
<!-- 出库子订单-->
<resultMap id="applicationOutRecordMin" type="com.dreamchaser.depository_manage.entity.ApplicationOutRecordMin">
<id property="id" column="aorid" jdbcType="INTEGER"/>
<id property="id" column="id" jdbcType="INTEGER"/>
<result column="mid" property="mid" jdbcType="INTEGER" />
<result column="depositoryId" property="depositoryId" jdbcType="INTEGER" />
<result column="placeId" property="placeId" jdbcType="INTEGER" />
@ -600,12 +600,10 @@
<!-- 插入一条出库记录-->
<insert id="insertApplicationOutRecord" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into application_out_record
(id,mid,depository_id,applicant_id,applicant_time,code,price,quantity,departmenthead,departmenthead_pass,departmenthead_time,
departmenthead_messgae,depository_manager,depository_manager_pass,depository_manager_time,depository_manager_message,apply_remark,state,istransfer,transferId,placeId)
(id,applicant_id,applicant_time,code,price,quantity,departmenthead,departmenthead_pass,departmenthead_time,
departmenthead_messgae,depository_manager,depository_manager_pass,depository_manager_time,depository_manager_message,apply_remark,state,istransfer,transferId,placeId,pass)
values(
#{id},
#{mid},
#{depositoryId},
#{applicantId},
#{applicantTime},
#{code},
@ -644,7 +642,8 @@
#{state},
#{istransfer},
#{transferId},
#{placeId}
#{placeId},
#{pass}
)
</insert>
@ -673,6 +672,35 @@
</select>
<select id="findApplicationOutMinByCondition" parameterType="int" resultMap="applicationOutRecordMin">
select
<include refid="ApplicationOutRecordMinInfo" />
from application_out_record_min as aorm
where 1 = 1
<if test="id != null and id != ''">
and aorm.id = #{id}
</if>
<if test="mid != null and mid != ''">
and aorm.mid = #{mid}
</if>
<if test="placeId != null">
and aorm.placeId = #{placeId}
</if>
<if test="quantity != null">
and aorm.quantity = #{quantity}
</if>
<if test="code != null">
and aorm.code = #{code}
</if>
<if test="checkId != null">
and aorm.checkId = #{checkId}
</if>
<if test="parentId != null">
and aorm.parentId = #{parentId}
</if>
</select>
<select id="findApplicationOutRecordMinByParent" parameterType="int" resultMap="applicationOutRecordMin">
select
<include refid="ApplicationOutRecordMinInfo" />
@ -823,6 +851,36 @@
WHERE id = #{id}
</update>
<!-- 修改子单-->
<update id="updateApplicationOutRecordMin">
update application_out_record_min
<set>
<if test="mid != '' and mid != null">
mid = #{mid},
</if>
<if test="depositoryId != '' and depositoryId != null">
depositoryId = #{depositoryId},
</if>
<if test="placeId != null">
placeId = #{placeId},
</if>
<if test="quantity != null">
quantity = #{quantity},
</if>
<if test="code != null">
code = #{code},
</if>
<if test="checkId != null">
checkId = #{checkId},
</if>
<if test="parentId != null ">
parentId = #{parentId}
</if>
where id = #{id}
</set>
</update>
<!-- 修改数据-->
<update id="updateApplicationOutRecord" parameterType="map">
UPDATE application_out_record
@ -876,7 +934,10 @@
state = #{state},
</if>
<if test="placeId != null">
placeId = #{placeId}
placeId = #{placeId},
</if>
<if test="pass != null and pass != ''">
pass = #{pass}
</if>
</set>
WHERE id = #{id}

2
target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

@ -245,7 +245,7 @@
<!-- 插入数据 -->
<insert id="insertMaterial" parameterType="map">
<insert id="insertMaterial" parameterType="map" useGeneratedKeys="true" keyProperty="id">
INSERT INTO material (
id, depository_id, mname, quantity, price, type_id,code,unit,version,texture,amounts,depositoryCode
) VALUES (

7
target/classes/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml

@ -146,12 +146,19 @@
FROM place p WHERE 1 = 1 and p.did = #{did}
</select>
<select id="findPlaceByMid" parameterType="int" resultMap="placeMap">
SELECT
<include refid="allColumns" />
FROM materialandplace mp left join place p on p.id = mp.pid WHERE 1 = 1 and mp.mid = #{mid}
</select>
<select id="findQuantityByMidAndPid" parameterType="map" resultType="int">
select quantity
from materialandplace
where pid = #{pid} and mid = #{mid}
</select>
<!-- 根据主键查询信息 -->
<select id="findPlaceById" resultMap="placeMap" parameterType="int">
SELECT

37
target/classes/templates/pages/application/application-out.html

@ -293,7 +293,7 @@
success: function (d) {
var d = d.data;
if(d == null){
layer.msg("没有该编码,请确认是否输入正确");
layer.msg("仓库中暂无该物料");
materialName.value = "";
materialId.value = "";
obj.value = "";
@ -400,8 +400,9 @@
var id = obj.id.split("quantity")[1];
var mcode = $("#code"+id).val(); // 获取到当前输入的物料编码
if(mcode === "" || mcode ===undefined || mcode === null){
layer.msg("请输入物料的正确编码!");
$("#quantity"+id).val("")
layer.msg("请输入物料的正确编码!",{icon:1,time:500},function () {
$("#quantity"+id).val("")
});
}else{
var req = {};
req.code = mcode;
@ -415,20 +416,22 @@
success:function (res) {
var flag = res.data;
if(!flag){ // 如果当前数目不合适
layer.msg("当前物料数量不足");
$("#quantity"+id).val("");
// 获取对应元素
var parent = obj.parentNode.parentNode.parentNode;
var children = parent.childNodes[5];
var codeChildren = parent.childNodes[7];
var materialItem = children.childNodes[3].childNodes[1].childNodes;
var materialName = materialItem[1];
var materialId = materialName.parentNode.parentNode.childNodes[3];
var codeItem = codeChildren.childNodes[3].childNodes;
var codeValue = codeItem[1];
materialName.value = "";
materialId.value = "";
codeValue.value = "";
layer.msg("当前物料数量不足",{icon:1,time:500},function () {
$("#quantity"+id).val("");
// 获取对应元素
var parent = obj.parentNode.parentNode.parentNode;
var children = parent.childNodes[5];
var codeChildren = parent.childNodes[7];
var materialItem = children.childNodes[3].childNodes[1].childNodes;
var materialName = materialItem[1];
var materialId = materialName.parentNode.parentNode.childNodes[3];
var codeItem = codeChildren.childNodes[3].childNodes;
var codeValue = codeItem[1];
materialName.value = "";
materialId.value = "";
codeValue.value = "";
});
}
}
});

121
target/classes/templates/pages/application/application-out_min.html

@ -0,0 +1,121 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
<link rel="stylesheet" href="/static/css/public.css" media="all">
<link rel="stylesheet" href="/static/js/lay-module/step-lay/step.css" media="all">
</head>
<body>
<div class="layuimini-container">
<div class="layuimini-main">
<input id="depositoryId" type="text" th:value="${depositoryId}" style="display: none">
<input id="state" type="text" th:value="${state}" style="display: none">
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
</div>
</div>
<script type="text/html" id="currentTableBar">
{{# if(d.state == "进行中"){ }}
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="scanQrCode">扫码</a>
{{# } }}
</script>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
layui.use(['form', 'table','laydate'], function () {
var $ = layui.jquery,
form = layui.form,
table = layui.table,
laydate = layui.laydate;
var depositoryId = $("#depositoryId").val();
// 0未完成1已完成
var state = $("#state").val();
table.render({
elem: "#currentTableId",
url: '/depositoryRecord/ApplicationOutMinByDid',
parseData: function (res) { //res 即为原始返回的数据
return {
"status": res.status, //解析接口状态
"message": res.statusInfo.message, //解析提示文本
"count": res.count, //解析数据长度
"data": res.data //解析数据列表
};
},
request: {
pageName: 'page', //页码的参数名称,默认:page
limitName: 'size' //每页数据量的参数名,默认:limit
},
where: {
"depositoryId":depositoryId,
"state":state
},
response: {
statusName: 'status' //规定数据状态的字段名称,默认:code
,statusCode: 200 //规定成功的状态码,默认:0
,msgName: 'message' //规定状态信息的字段名称,默认:msg
,countName: 'count' //规定数据总数的字段名称,默认:count
,dataName: 'data' //规定数据列表的字段名称,默认:data
},
toolbar: '#toolbarDemo',
//这里layui和thymeleaf冲突了,要加个空格
cols: [ [
{title: '操作', width: 100, toolbar: '#currentTableBar', align: "center"},
{field: 'id', width: 100, title: '提交编号', sort: true},
{field: 'code', width: 200, title: '提交编码', sort: true},
{field: 'mname', width: 120, title: '物料名称'},
{field: 'mcode', width: 120, title: '物料编码'},
{field: 'depositoryName', width: 120, title: '仓库名称'},
{field: 'pcode', width: 120, title: '库位编码'},
{field: 'quantity', width: 80, title: '数量', sort: true},
{field: 'applicantName', width: 150, title: '申请人'},
{field: 'applicantTime', width: 200, title: '申请时间', sort: true},
{field: 'applyRemark', width: 200, title: '备注'},
{field: 'state', width: 200, title: '状态'}
]],
limits: [10, 15, 20, 25, 50],
limit: 10,
page: true,
skin: 'line',
done:function () {
$("[data-field='id']").css('display','none');
}
});
table.on('tool(currentTableFilter)', function (obj) {
let data = obj.data;
if (obj.event === 'scanQrCode') {
layer.open({
type: 2,
title: '扫码',
skin: 'layui-layer-rim',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['100%', '100%'],
move : '.layui-layer-title',
fixed:false,
content: '/scanQrCodeByOut?id='+data.id,
end:function () {
table.reload('currentTableId', {
url: '/depositoryRecord/ApplicationOutMinByDid',
page: {
curr: 1
}
}, 'data');
}
})
}
})
});
</script>
</body>
</html>

29
target/classes/templates/pages/application/application-review.html

@ -54,6 +54,7 @@
<tr>
<td>状态</td>
<td id="state" th:text="${record.getState()}">状态</td>
<td id="pass" th:text="${record.getPass()}" style="display:none;"></td>
</tr>
<tr>
<td>申请人</td>
@ -81,8 +82,8 @@
<td id="departmentheadTime" th:text="${record.getDepartmentheadTime().equals('1970-01-01 08:00:00')?'':record.getDepartmentheadTime()}">1970-01-01 08:00:00</td>
</tr>
<tr id="depositoryManagerNameT" style="display: none">
<td>库管理员</td>
<td id="depositoryManagerName" th:text="${record.getDepositoryManagerName()}">库管理员</td>
<td>储负责人</td>
<td id="depositoryManagerName" th:text="${record.getDepositoryManagerName()}">储负责人</td>
</tr>
</tbody>
</table>
@ -159,6 +160,7 @@
step = layui.step;
var state=$("#state").text();
var pass = $("#pass").text();
//当前处于的状态
var position=0,states={},number = 1;
if (state === "待部门负责人审核" || state === "部门负责人审核未通过") {
@ -166,9 +168,21 @@
states = [ {title: state}];
number = 2;
} else {
// {title: "提交申请"},
states = [ {title: state}];
number = 3;
if(state === "待仓储中心负责人审核"|| state === "仓储中心负责人审核未通过"){
states = [ {title: state}];
number = 3;
}else{
if(pass === 1 || pass === "1"){
number = 4;
states = [{title:"已出库"}]
}else if(pass === 3 || pass === "3"){
number = 4;
states = [{title:"出库中"}]
}else if(pass === 2 || pass === "2"){
number = 4;
states = [{title:"未出库"}]
}
}
}
step.render({
elem: '#stepForm',
@ -199,7 +213,7 @@
}
data.departmentheadMessage=$("#departmentheadMessageF").val();
send(data);
}
};
check=function(pass) {
let data={};
data.id=$("#id").text();
@ -210,9 +224,8 @@
}
data.depositoryManagerMessage=$("#depositoryManagerMessageF").val();
send(data);
}
};
function send(req) {
console.log(JSON.stringify(req));
$.ajax({
url:"/depositoryRecord/review",
type:'put',

13
target/classes/templates/pages/application/application_multi.html

@ -68,6 +68,7 @@
{field: 'version', width: '10%', title: '规格型号'},
{field: 'code',width: 200,title: '存货编码',sort: true},
{field: 'depositoryName', width: '12%', title: '仓库名称'},
{field: 'placeCode', width: '12%', title: '库位编码'},
{field: 'quantity', width: '10%', title: '数量',edit:'quantity'},
{field: 'price', width: '10%', title: '单价',edit:'price'},
{field: 'depositoryId', width: '10%', title: '仓库编号',edit:'quantity'},
@ -107,15 +108,19 @@
req.quantitys = [];
req.applyRemarks = [];
req.prices = [];
req.placeCodes = [];
for (i = 0, len = data.length; i < len; i++) {
req.mids[i] = data[i].mid;
req.depositoryIds[i] = data[i].depositoryId;
req.quantitys[i] = data[i].quantity;
req.applyRemarks[i] = data[i].applyRemark;
req.prices[i] = data[i].price;
req.placeCodes[i] = data[i].placeCode;
}
if(obj.event==='delete'){
if(req.mids > 0) {
console.log(req)
if(req.mids.length > 0) {
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
$.ajax({
url: "/depositoryRecord/deleteApplicationToRedis",
@ -186,7 +191,11 @@
if (d.status >= 300) {
layer.msg(d.statusInfo.message);//失败的表情
return;
} else {
}else if(d.status === 1234){
layer.msg(d.data)
return
}
else {
layer.msg("申请成功!", {
icon: 6,//成功的表情
time: 1000

28
target/classes/templates/pages/application/form-step-look_back.html

@ -53,6 +53,7 @@
<tr>
<td>状态</td>
<td id="state" th:text="${record.getState()}">2016-11-28</td>
<td id="pass" th:text="${record.getPass()}" style="display:none;"></td>
</tr>
<tr>
<td>申请人</td>
@ -80,15 +81,15 @@
<td id="departmentheadTime" th:text="${record.getDepartmentheadTime().equals('1970-01-01 08:00:00')?'':record.getDepartmentheadTime()}">2016-11-28</td>
</tr>
<tr id="depositoryManagerNameT" style="display: none">
<td>库管理员</td>
<td id="depositoryManagerName" th:text="${record.getDepositoryManagerName()}">2016-11-28</td>
<td>储负责人</td>
<td id="depositoryManagerName" th:text="${record.getDepositoryManagerName()}">仓储负责人</td>
</tr>
<tr id="depositoryManagerNameMessageT" style="display: none">
<td>库管理员备注</td>
<td>储负责人备注</td>
<td id="depositoryManagerNameMessage" th:text="${record.getDepositoryManagerMessage()}">2016-11-28</td>
</tr>
<tr id="depositoryManagerNameTimeT" style="display: none">
<td>库管理员审核时间</td>
<td>储负责人审核时间</td>
<td id="depositoryManagerNameTime" th:text="${record.getDepositoryManagerTime().equals('1970-01-01 08:00:00')?'':record.getDepositoryManagerTime()}">2016-11-28</td>
</tr>
@ -121,6 +122,7 @@
var state=$("#state").text();
var pass=$("#pass").text();
//当前处于的状态
var position=0,states={},number = 1;
@ -128,8 +130,22 @@
states = [ {title: state}];
number = 2;
} else {
states = [ {title: state}];
number = 3;
if(state === "待仓储中心负责人审核"|| state === "仓储中心负责人审核未通过"){
states = [ {title: state}];
number = 3;
}else{
if(pass === 1 || pass === "1"){
number = 4;
states = [{title:"已出库"}]
}else if(pass === 3 || pass === "3"){
number = 4;
states = [{title:"出库中"}]
}else if(pass === 2 || pass === "2"){
number = 4;
states = [{title:"未出库"}]
}
}
}
step.render({
elem: '#stepForm',

128
target/classes/templates/pages/application/my-task.html

@ -28,13 +28,27 @@
<fieldset class="layui-elem-field layui-field-title">
<legend>未完成任务</legend>
</fieldset>
<fieldset class="layui-elem-field layui-field-title">
<legend>审核任务</legend>
</fieldset>
<ul id="LAY_floor1" class="flow-default" style="width: 100%"></ul>
<fieldset class="layui-elem-field layui-field-title">
<legend>出库任务</legend>
</fieldset>
<ul id="LAY_floor3" class="flow-default" style="width: 100%"></ul>
</div>
<div class="layui-bg-gray" style="padding: 10px;">
<fieldset class="layui-elem-field layui-field-title">
<legend>已完成任务</legend>
</fieldset>
<fieldset class="layui-elem-field layui-field-title">
<legend>审核任务</legend>
</fieldset>
<ul id="LAY_floor2" class="flow-default" style="width: 100%"></ul>
<fieldset class="layui-elem-field layui-field-title">
<legend>出库任务</legend>
</fieldset>
<ul id="LAY_floor4" class="flow-default" style="width: 100%"></ul>
</div>
@ -51,6 +65,13 @@
//先声明
function openDetail2(data) {
};
//先声明
function openDetail3(data) {
};
//先声明
function openDetail4(data) {
};
layui.use(['flow', 'layer', 'table', 'util'], function () {
var $ = layui.jquery,
layer = layui.layer,
@ -77,7 +98,7 @@
}
lis.push('<li style="width:'+ Width +';float:left;"><div class="layui-card my-shadow my-card flow1" onclick="openDetail1('
+result[i].id+')"><div class="layui-card-header"><h2>'
+result[i].applicantName+'的')
+result[i].applicantName+'的');
lis.push('出库请求</h2></div>');
lis.push('<div class="layui-col-md4 my-time" style="margin-left: 15px; color: #999;font-size: 12px;">'
+result[i].applicantTime+'</div></div></li>');
@ -124,7 +145,73 @@
});
}
});
flow.load({
elem: '#LAY_floor3' //流加载容器
,scrollElem: '#LAY_floor3' //滚动条所在元素,一般不用填,此处只是演示需要。
,isAuto:false
,done: function(page, next){ //执行下一页的回调
let lis = [];
let result;
$.get('/depositoryRecord/myTashForScanQrCode?page='+page+'&size='+size+'&isDone=0', function(res){
var Width = "25%";
result=res.data;
const keys = Object.keys(result); // 获取map中所有的键
lis.push("<div class='clearfix'>");
for (let i = 0; i < keys.length; i++) {
if(isMobile()){
Width = "50%";
}
lis.push('<li style="width:'+ Width +';float:left;"><div class="layui-card my-shadow my-card flow1" onclick="openDetail3('
+result[keys[i]][0].depositoryId+')" ><div class="layui-card-header"><h2>'
+result[keys[i]][0].depositoryName+'</h2></div>')
lis.push('<div class="layui-col-md4 my-time" style="margin-left: 15px; color: #999;font-size: 12px;">'
+result[keys[i]][0].applicantTime+'</div></div></li>');
}
lis.push("</div>")
pre2+=result.length;
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(''), pre2 < res.count);
});
}
});
flow.load({
elem: '#LAY_floor4' //流加载容器
,scrollElem: '#LAY_floor4' //滚动条所在元素,一般不用填,此处只是演示需要。
,isAuto:false
,done: function(page, next){ //执行下一页的回调
let lis = [];
let result;
$.get('/depositoryRecord/myTashForScanQrCode?page='+page+'&size='+size+'&isDone=1', function(res){
var Width = "25%";
result=res.data;
const keys = Object.keys(result); // 获取map中所有的键
lis.push("<div class='clearfix'>");
for (let i = 0; i < keys.length; i++) {
if(isMobile()){
Width = "50%";
}
lis.push('<li style="width:'+ Width +';float:left;"><div class="layui-card my-shadow my-card flow1" onclick="openDetail4('
+result[keys[i]][0].depositoryId+')" ><div class="layui-card-header"><h2>'
+result[keys[i]][0].depositoryName+'</h2></div>')
lis.push('<div class="layui-col-md4 my-time" style="margin-left: 15px; color: #999;font-size: 12px;">'
+result[keys[i]][0].applicantTime+'</div></div></li>');
}
lis.push("</div>")
pre2+=result.length;
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(''), pre2 < res.count);
});
}
});
openDetail1 = function (item) {
var index = layer.open({
title: '请求详情',
@ -142,7 +229,7 @@
$(window).on("resize", function () {
layer.full(index);
});
}
};
openDetail2 = function (item) {
var index = layer.open({
title: '请求详情',
@ -159,7 +246,42 @@
$(window).on("resize", function () {
layer.full(index);
});
}
};
openDetail3 = function (item) {
var index = layer.open({
title: '请求详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/ApplicationOutMinByDid?depositoryId='+item+"&state=0",
end:function () {
location.reload()
}
});
$(window).on("resize", function () {
layer.full(index);
});
};
openDetail4 = function (item) {
var index = layer.open({
title: '请求详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/ApplicationOutMinByDid?depositoryId='+item+"&state=1",
end:function () {
location.reload()
}
});
$(window).on("resize", function () {
layer.full(index);
});
};
//定义一个函数判断是手机端还是pc端
function isMobile(){

5
target/classes/templates/pages/depository/table-in.html

@ -142,7 +142,10 @@
limits: [10, 15, 20, 25, 50],
limit: 10,
page: true,
skin: 'line'
skin: 'line',
done:function () {
$("[data-field='id']").css('display','none');
}
});
// 监听搜索操作

11
target/classes/templates/pages/depository/table-out.html

@ -135,10 +135,19 @@
{field: 'quantity', width: 80, title: '数量', sort: true},
{field: 'price', title: '金额', minWidth: 80, sort: true},
{field: 'state', width: 150, title: '流程状态'},
{
field: 'pass', title: '是否完成出库', minWidth: 120, templet: function (d) {
if (d.pass == 1){
return "是";
}else{
return "否";
}
}
},
{field: 'applicantName', width: 150, title: '申请人'},
{field: 'applicantTime', width: 200, title: '申请时间', sort: true},
{
field: 'istransfer', title: '是否为转移申请', minWidth: 80, templet: function (d) {
field: 'istransfer', title: '是否为转移申请', minWidth: 120, templet: function (d) {
if (d.istransfer == 1){
return "是";
}else if(d.istransfer == 2){

2
target/classes/templates/pages/depository/table-stock.html

@ -179,9 +179,11 @@
var req = {};
req.mids = [];
req.depositoryIds = [];
req.placeCodes = [];
for (i = 0, len = data.length; i < len; i++) {
req.mids[i] = data[i].id;
req.depositoryIds[i] = data[i].depositoryId;
req.placeCodes[i] = data[i].placeCode;
}
if(req.mids.length > 0) {
$.ajax({

9
target/classes/templates/pages/material/material-out.html

@ -46,6 +46,12 @@
<input type="text" name="mname" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">存货编码</label>
<div class="layui-input-inline">
<input type="text" name="code" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">状态</label>
<div class="layui-input-inline">
@ -198,6 +204,9 @@
if(data.state != ''){
req.state = data.state;
}
if(data.code != ''){
req.code = data.code
}
//执行搜索重载
table.reload('currentTableId', {

1
target/classes/templates/pages/material/selectType.html

@ -36,7 +36,6 @@
contentType: "application/json;charset=utf-8",
success: function (d) {
var data2 = d.data
console.log(data2)
test.reload({
data:data2
});

1
target/classes/templates/pages/place/place_edit.html

@ -92,7 +92,6 @@
layer = layui.layer;
var depositoryId = $("#depositoryId").val();
console.log(depositoryId);
form.on('submit(formStep)', function (data) {
var req = data.field;
req.type = "one";

1
target/classes/templates/pages/post/postRole_add.html

@ -96,7 +96,6 @@
success: function (data) {
layer.close(this.layerIndex);
if (data.status >= 300) {
console.log(data)
layer.msg(data.statusInfo.message,{
icon: 7,
time: 200

150
target/classes/templates/pages/scanQrCode/scanQrCode2.html

@ -1,150 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="ZXing for JS">
<title>ZXing TypeScript | Decoding from camera stream</title>
<!-- <link rel="stylesheet" rel="preload" as="style" onload="this.rel='stylesheet';this.onload=null" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">-->
<!-- <link rel="stylesheet" rel="preload" as="style" onload="this.rel='stylesheet';this.onload=null" href="https://unpkg.com/normalize.css@8.0.0/normalize.css">-->
<!-- <link rel="stylesheet" rel="preload" as="style" onload="this.rel='stylesheet';this.onload=null" href="https://unpkg.com/milligram@1.3.0/dist/milligram.min.css">-->
</head>
<body>
<main class="wrapper" style="padding-top:2em">
<section class="container" id="demo-content">
<div>
<a class="button" id="startButton">扫描</a>
<a class="button" id="resetButton">重置</a>
</div>
<div>
<video id="video" width="300" height="200" style="border: 1px solid gray"></video>
</div>
<div id="sourceSelectPanel" style="display:none">
<label for="sourceSelect">选择摄像头: </label>
<select id="sourceSelect" style="max-width:400px">
</select>
</div>
<div style="display: table">
<label for="decoding-style"> 扫描次数:</label>
<select id="decoding-style" size="1">
<option value="once">扫描一次</option>
<option value="continuously">持续扫描</option>
</select>
</div>
<label>结果:</label>
<pre><code id="result"></code></pre>
</section>
</main>
<script type="text/javascript" src="https://unpkg.com/@zxing/library@latest"></script>
<script type="text/javascript">
function decodeOnce(codeReader, selectedDeviceId) {
codeReader.decodeFromInputVideoDevice(selectedDeviceId, 'video').then((result) => {
console.log(result);
document.getElementById('result').textContent = result.text
}).catch((err) => {
console.error(err);
document.getElementById('result').textContent = err
})
}
function decodeContinuously(codeReader, selectedDeviceId) {
codeReader.decodeFromInputVideoDeviceContinuously(selectedDeviceId, 'video', (result, err) => {
if (result) {
// properly decoded qr code
console.log('Found QR code!', result);
document.getElementById('result').textContent = result.text
}
if (err) {
if (err instanceof ZXing.NotFoundException) {
console.log('No QR code found.')
}
if (err instanceof ZXing.ChecksumException) {
console.log('A code was found, but it\'s read value was not valid.')
}
if (err instanceof ZXing.FormatException) {
console.log('A code was found, but it was in a invalid format.')
}
}
})
}
window.addEventListener('load', function () {
let selectedDeviceId;
const codeReader = new ZXing.BrowserQRCodeReader();
console.log('ZXing 初始化');
codeReader.getVideoInputDevices()
.then((videoInputDevices) => {
const sourceSelect = document.getElementById('sourceSelect')
// selectedDeviceId = videoInputDevices[0].deviceId;
if (videoInputDevices.length >= 1) {
videoInputDevices.forEach((element) => {
const sourceOption = document.createElement('option');
console.log(element.label);
if(element.label.includes("front")){
sourceOption.text = "前置摄像头";
sourceOption.value = element.deviceId;
}else if (element.label.includes("back")){
sourceOption.text = "后置摄像头";
sourceOption.selected=true;
sourceOption.value = element.deviceId;
selectedDeviceId = element.deviceId;
}
sourceSelect.appendChild(sourceOption)
});
sourceSelect.onchange = () => {
selectedDeviceId = sourceSelect.value;
};
const sourceSelectPanel = document.getElementById('sourceSelectPanel')
sourceSelectPanel.style.display = 'block'
}
document.getElementById('startButton').addEventListener('click', () => {
const decodingStyle = document.getElementById('decoding-style').value;
if (decodingStyle === "once") {
// 如果只扫描一次
decodeOnce(codeReader, selectedDeviceId);
} else {
// 扫描多次
decodeContinuously(codeReader, selectedDeviceId);
}
console.log(`Started decode from camera with id ${selectedDeviceId}`)
});
document.getElementById('resetButton').addEventListener('click', () => {
codeReader.reset();
document.getElementById('result').textContent = '';
console.log('Reset.')
})
})
.catch((err) => {
console.error(err)
})
})
</script>
</body>
</html>

332
target/classes/templates/pages/scanQrCode/scanQrCodeOut.html

@ -0,0 +1,332 @@
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>扫码</title>
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
<link rel="stylesheet" href="/static/css/layuimini.css?v=2.0.4.2" media="all">
<link rel="stylesheet" href="/static/css/themes/default.css" media="all">
<link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
<!--[if lt IE 9]>
<script src="/static/js/html5.min.js"></script>
<script src="/static/js/respond.min.js"></script>
<![endif]-->
<!-- vue相关-->
<script src="../static/js/vue/vue.js"></script>
<script src="../static/js/vue/vue-router.js"></script>
<script src="../static/lib/http-vue-loader/src/httpVueLoader.js"></script>
<script src="../static/js/VueQrcodeReader.umd.min.js"></script>
<style>
.validation-success,
.validation-failure,
.validation-pending {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, .8);
text-align: center;
font-weight: bold;
font-size: 1.4rem;
padding: 10px;
display: flex;
flex-flow: column nowrap;
justify-content: center;
}
.validation-success {
color: green;
}
.validation-failure {
color: red;
}
</style>
</head>
<body>
<div id="app">
<input id="id" style="display: none" th:value="${record.getId()}">
<input id="mcode" style="display: none" th:value="${materialById.getCode()}">
<input id="depositoryId" style="display: none" th:value="${record.getDepositoryId()}">
<input id="quantity" style="display: none" th:value="${record.getQuantity()}">
<qrcode-stream :camera="camera" @decode="onDecode" @init="onInit" :track="paintBoundingBox">
<div v-if="validationPending" class="validation-pending">
Long validation in progress...
</div>
</qrcode-stream>
</div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
Vue.use(httpVueLoader);
let id = layui.$("#id").val();
let mcode = layui.$("#mcode").val();
let depositoryId = layui.$("#depositoryId").val();
let quantity = layui.$("#quantity").val();
var vue = new Vue({
data() {
return {
isValid: undefined,
camera: 'auto',
result: '',
error: '',
material: null,
depository: null,
place: null
}
},
computed: {
validationPending() {
return this.isValid === undefined
&& this.camera === 'off'
},
},
methods: {
onDecode(result) {
let params = {}; // 用于暂存扫描结果
this.result = result;
let parse = JSON.parse(result);
vue.turnCameraOff(); // 暂停扫描
if (parse.did !== undefined) {
//如果扫描的为仓库
this.depository = parse;// 将扫描结果保存到vue中
if(this.material == null){
// 如果还没有扫描物料
layer.confirm("请扫描物料", {
btn:["扫描","取消"]
},function () { // 继续
vue.turnCameraOn(); // 继续扫描
layer.close(layer.index); // 关闭弹窗
},function () { // 取消
// 将vue中暂存的数据置为空
this.depository = null;
this.place = null;
this.material = null;
})
}
else{
// 如果已经扫描物料
if(depositoryId !== parse.did && Number(depositoryId) !== parse.did && depositoryId !== parse.did.toString()){
// 如果当前仓库不是订单对应仓库
this.depository = null;
this.place = null;
layer.msg("出库仓库不正确,请重新扫描");
this.turnCameraOn()
}else{
var req = {};
req.id = id;
vue.isOutTrue(req);
}
}
}
else if (parse.pid !== undefined){
// 如果扫描的为库位
this.place = parse;// 将扫描结果保存到vue中
if(this.material == null){
// 如果还没有扫描物料
layer.confirm("请扫描物料", {
btn:["扫描","取消"]
},function () { // 继续
vue.turnCameraOn(); // 继续扫描
layer.close(layer.index); // 关闭弹窗
},function () { // 取消
// 将vue中暂存的库位置为空
this.place = null;
})
}else{
if(depositoryId !== parse.depositoryId && Number(depositoryId) !== parse.depositoryId && depositoryId !== parse.depositoryId.toString()){
// 如果当前仓库不是订单对应仓库
this.depository = null;
this.place = null;
layer.msg("出库库位所在仓库不正确,请重新扫描");
this.turnCameraOn()
}else if(parse.mcodeList.indexOf(mcode) === -1){
// 如果当前库位不存在该物料
this.depository = null;
this.place = null;
layer.msg("出库库位不含该物料,请重新扫描");
this.turnCameraOn()
}
else{
var req = {};
req.placeId= this.place.pid;
req.id = id;
vue.isOutTrue(req);
}
}
}
else if (parse.mid !== undefined){
// 如果扫描的为物料
this.material = parse;// 将扫描结果保存到vue中
if(mcode !== this.material.code && Number(mcode) !== this.material.code && mcode !== this.material.code.toString()){
this.material = null;
layer.msg("出库物料不正确,请重新扫描");
this.turnCameraOn()
}
else {
if (this.depository !== null) { // 如果已经扫描仓库
let depository = this.depository;
if (depositoryId !== depository.did && Number(depositoryId) !== depository.did && depositoryId !== depository.did.toString()) {
// 如果扫描的仓库不是订单要求的仓库
layer.confirm("当前仓库不符合要求,请移步至正确仓库", {
btn: ["确定"]
}, function () {
// 将vue中仓库设为空
vue.depository = null;
layer.close(layer.index); // 关闭弹窗
})
} else {
// 如果是出库位置为默认库位
var req = {};
req.id = id;
// 弹出确定框
vue.isOutTrue(req);
}
}
else if(this.place != null){
// 如果已经扫描库位
if(depositoryId !== this.place.depositoryId && Number(depositoryId) !== this.place.depositoryId && depositoryId !== this.place.depositoryId.toString()){
// 如果当前仓库不是订单对应仓库
this.depository = null;
this.place = null;
layer.msg("出库库位所在仓库不正确,请重新扫描");
this.turnCameraOn()
}else if(this.place.mcodeList.indexOf(mcode) === -1){
// 如果当前库位不存在该物料
this.depository = null;
this.place = null;
layer.msg("出库库位不含该物料,请重新扫描");
this.turnCameraOn()
}
else{
var req = {};
req.id = id;
req.placeId= this.place.pid;
// 弹出确定框
vue.isOutTrue(req);
}
}
else {
layer.confirm("请扫描仓库或库位", {
btn: ["扫描", "取消"]
}, function () { // 继续
vue.turnCameraOn(); // 继续扫描
layer.close(layer.index); // 关闭弹窗
}, function () { // 取消
// 将vue中暂存的库位置为空
this.material = null;
})
}
}
}
},
async onInit(promise) {
try {
await promise.then(this.resetValidationState)
} catch (error) {
if (error.name === 'NotAllowedError') {
this.error = "ERROR: you need to grant camera access permission"
} else if (error.name === 'NotFoundError') {
this.error = "ERROR: no camera on this device"
} else if (error.name === 'NotSupportedError') {
this.error = "ERROR: secure context required (HTTPS, localhost)"
} else if (error.name === 'NotReadableError') {
this.error = "ERROR: is the camera already in use?"
} else if (error.name === 'OverconstrainedError') {
this.error = "ERROR: installed cameras are not suitable"
} else if (error.name === 'StreamApiNotSupportedError') {
this.error = "ERROR: Stream API is not supported in this browser"
} else if (error.name === 'InsecureContextError') {
this.error = 'ERROR: Camera access is only permitted in secure context. Use HTTPS or localhost rather than HTTP.';
} else {
this.error = `ERROR: Camera error (${error.name})`
}
console.log(this.error)
}
}
,
resetValidationState() {
this.isValid = undefined
}
,
// 绘制二维码跟踪框
paintBoundingBox(detectedCodes, ctx) {
for (const detectedCode of detectedCodes) {
const {boundingBox: {x, y, width, height}} = detectedCode;
ctx.lineWidth = 2;
ctx.strokeStyle = '#007bff';
ctx.strokeRect(x, y, width, height)
}
}
,
// 打开相机
turnCameraOn() {
this.camera = 'auto'
}
,
// 关闭相机
turnCameraOff() {
this.camera = 'off'
},
// 将扫描到的数据暂存到redis
temporaryScanValue(params) {
layui.$.ajax({
url: "/material/temporaryValue",
type: 'post',
dataType: 'json',
contentType: "application/json;charset=utf-8",
data: JSON.stringify(params)
});
},
// 弹出出库确定弹出框
isOutTrue(req){
layer.confirm("确定出库?", {
btn: ["确定", "取消"]
}, function () { // 如果确定出库
layui.$.ajax({
url: "/depositoryRecord/isCheckOut",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (res) {
if (res.status === 200) {
// 如果出库成功
layer.msg("出库成功",
{icon:6,
time:500
}
, function () {
layer.close(layer.index);
});
layer.close(layer.index)
} else {
// 如果出库失败
layer.msg(res.statusInfo.message+",请重试");
vue.depository = null;
vue.material = null;
vue.place = null;
// 继续扫描
vue.turnCameraOn();
return
}
}
})
}, function () {
// 如果取消
vue.depository = null;
vue.material = null;
vue.place = null;
})
}
}
}).$mount('#app')
</script>
</body>
</html>
Loading…
Cancel
Save