Browse Source

完成拆单的出库、入库、库存转移功能

lwx_dev
erdanergou 3 years ago
parent
commit
458e4ec809
  1. 5
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 101
      src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java
  3. 8
      src/main/java/com/dreamchaser/depository_manage/controller/PageController.java
  4. 11
      src/main/java/com/dreamchaser/depository_manage/controller/PlaceController.java
  5. 2
      src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml
  6. 4
      src/main/java/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.xml
  7. 15
      src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java
  8. 445
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  9. 64
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  10. 172
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java
  11. 1
      src/main/resources/static/js/application-out/application-out.js
  12. 7
      src/main/resources/templates/pages/application/application-out.html
  13. 187
      src/main/resources/templates/pages/application/application-out_back.html
  14. 124
      src/main/resources/templates/pages/application/application-transfer.html
  15. 2
      src/main/resources/templates/pages/material/selectDepositoryByCard.html
  16. 10
      src/main/resources/templates/pages/scanQrCode/ScanBarOrQrCodeOut.html
  17. 2
      target/classes/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml
  18. 4
      target/classes/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.xml
  19. 1
      target/classes/static/js/application-out/application-out.js
  20. 7
      target/classes/templates/pages/application/application-out.html
  21. 187
      target/classes/templates/pages/application/application-out_back.html
  22. 124
      target/classes/templates/pages/application/application-transfer.html
  23. 2
      target/classes/templates/pages/material/selectDepositoryByCard.html
  24. 18
      target/classes/templates/pages/scanQrCode/ScanBarOrQrCodeOut.html

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

@ -223,6 +223,7 @@ public class DepositoryRecordController {
insert.put("qrCode", map.get("qrCode" + temp));
insert.put("barCode", map.get("barCode" + temp));
insert.put("unit",map.get("unit" + temp));
insert.put("placeId",map.get("placeId" + temp));
String unit = (String)(map.get("unit" + temp));
if (!"-1".equals(unit)) {
insert.put("type","in");
@ -777,6 +778,7 @@ public class DepositoryRecordController {
insert.put("code", map.get("code" + temp));
insert.put("placeId", map.get("placeId" + temp));
insert.put("fromPlaceId", map.get("fromPlaceId" + temp));
insert.put("unit",map.get("unit"+temp));
Object parentId = map.get("parentId");
if (parentId != null) {
insert.put("parentId", parentId);
@ -1226,8 +1228,7 @@ public class DepositoryRecordController {
if (barCode != null) {
map.put("barCode", barCode);
}
RestResponse restResponse = depositoryRecordService.completeApplicationOutMinRecord(map, userToken, crypt);
return restResponse;
return depositoryRecordService.completeApplicationOutMinRecord(map, userToken, crypt);
}

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

@ -130,8 +130,8 @@ public class MaterialController {
size = ObjectFormatUtil.toInteger(map.get("size"));
}
if (!(map.containsKey("depositoryId") || map.containsKey("code") || map.containsKey("mname"))) {
for (int i = 0; i < depositoryByAdminorg.size(); i++) {
Integer did = depositoryByAdminorg.get(i).getId();
for (Depository depository : depositoryByAdminorg) {
Integer did = depository.getId();
didList.add(did);
map.put("depositoryId", did);
List<InventoryP> inventory = materialService.findInventory(map);
@ -450,17 +450,37 @@ public class MaterialController {
}
@PostMapping("/findInventoryByCondition")
public RestResponse findInventoryByCondition(@RequestBody Map<String, Object> map) {
List<InventoryP> materialPByCondition = materialService.findInventory(map);
public RestResponse findInventoryByCondition(@RequestBody Map<String, Object> map, HttpServletRequest request) {
UserByPort userToken = (UserByPort) request.getAttribute("userToken");
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString());
List<InventoryP> inventoryPList = new ArrayList<>();
for (Depository value : depositoryByAdminorg) {
map.put("depositoryId", value.getId());
List<InventoryP> inventoryPS = materialService.findInventory(map);
inventoryPList.addAll(inventoryPS);
}
Map<String, Object> paramByBarcode = new HashMap<>();
for (InventoryP inventoryP : materialPByCondition) {
for (InventoryP inventoryP : inventoryPList) {
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(inventoryP.getMid());
inventoryP.setSplitInfoList(splitInfoByMid);
paramByBarcode.put("mcode", inventoryP.getCode());
List<MaterialAndBarCode> materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(paramByBarcode);
inventoryP.setMaterialAndBarCodeList(materialByBarCodeByCondition);
List<PlaceP> placeList = new ArrayList<>();
for (Depository depository : depositoryByAdminorg) {
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(inventoryP.getId(), depository.getId());
for (PlaceP placeP : placeByMidAndDid) {
int index = placeList.indexOf(placeP);
if (index == -1) {
placeList.add(placeP);
}
}
}
return new RestResponse(materialPByCondition, materialService.findInventoryCount(map), 200);
inventoryP.setPlacePList(placeList);
}
return new RestResponse(inventoryPList, materialService.findInventoryCount(map), 200);
}
@ -540,8 +560,8 @@ public class MaterialController {
ArrayList<Object> newMaterialList = new ArrayList();
Map<String, Object> map = new HashMap<>();
for (int i = 0; i < materialList.size(); i++) {
JSONObject obj = (JSONObject) materialList.get(i);
for (Object o : materialList) {
JSONObject obj = (JSONObject) o;
map.put("code", obj.get("code"));
if (depository != null) {
map.put("depositoryId", depository.get("did"));
@ -585,6 +605,10 @@ public class MaterialController {
boolean flag = false;
map.remove("quantity");
// 获取当前用户所在部门关闭的仓库及公共仓库
Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId"));
map.remove("placeId");
if (Integer.compare(placeId, -1) == 0) {
// 如果是查询所有库存
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userByPort.getMaindeparment().toString());
for (Depository depository : depositoryByAdminorg) {
map.put("depositoryId", depository.getId());
@ -611,18 +635,29 @@ public class MaterialController {
SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取最高级对应当前单位的数量
int saveQuantity = inventoryP.getQuantity() * splitUnitService.findSplitInfoScaleQuantity(splitInfo,-1);
SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(inventoryP.getId(), splitInfo.getId());
int saveQuantity = inventoryP.getQuantity() * splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
// 获取当前物料所在库位
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(inventoryP.getId(), depository.getId());
for (PlaceP p :
placeByMidAndDid) {
// 获取对应关系
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(p.getId(), inventoryP.getId());
if (placeAndMaterialByMidAndPid != null) {
SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId());
saveQuantity += splitInventory.getSaveQuantity();
SplitInfo parentSplitInfo = splitUnitService.findSplitInfoById(splitInfo.getParentId());;
while (parentSplitInfo != null){
splitInventory = splitUnitService.findSplitInventoryByIidAndSid(inventoryP.getId(), parentSplitInfo.getId());
SplitInfo parentSplitInfo = splitUnitService.findSplitInfoById(splitInfo.getParentId());
;
while (parentSplitInfo != null) {
splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), parentSplitInfo.getId());
splitInfo = splitUnitService.findSplitInfoByParentId(parentSplitInfo.getId());
saveQuantity += splitInventory.getSaveQuantity() * splitInfo.getQuantity();
parentSplitInfo = splitUnitService.findSplitInfoById(parentSplitInfo.getParentId());
}
}
}
if (quantity <= saveQuantity) { // 如果当前数量合适则跳出循环
flag = true;
break;
@ -631,6 +666,41 @@ public class MaterialController {
}
}
}
} else {
// 获取当前要转移的库位
Place place = placeService.findPlaceById(placeId);
if (Integer.compare(place.getId(), 0) != 0) {
map.put("depositoryId", place.getDid());
}
// 根据条件查询库存
List<InventoryP> inventoryPList = materialService.findInventory(map);
for (InventoryP inventoryP :
inventoryPList) {
// 获取当前库位上的物料映射关系
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(placeId, inventoryP.getId());
if ("-1".equals(unit)) {
// 如果是基础单位
if (quantity <= placeAndMaterialByMidAndPid.getQuantity()) { // 如果当前数量合适则跳出循环
flag = true;
break;
}
} else {
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid", inventoryP.getMid());
paramForSplitInfo.put("newUnit", unit);
// 查询当前拆单记录
SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 查询以当前拆单记录为基础单位的库存
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
if (quantity <= allInventoryForSplitInfo) {
flag = true;
break;
}
}
}
}
return new RestResponse(flag);
}
@ -774,6 +844,9 @@ public class MaterialController {
mp.setPlacePList(placePList);
// 设置物料与条形码的对应关系
mp.setMaterialAndBarCodeList(materialByBarCodeByCondition);
// 获取拆单信息
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(mp.getMid());
mp.setSplitInfoList(splitInfoByMid);
}
return new RestResponse(mp);

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

@ -700,7 +700,7 @@ public class PageController {
public ModelAndView application_out_back(String code, String depositoryId) {
ModelAndView mv = new ModelAndView();
mv.setViewName("pages/application/application-out_back");
InventoryP materialById = new InventoryP();
InventoryP inventoryP = new InventoryP();
if (code != null) {
Map<String, Object> map = new HashMap<>();
Depository depositoryByCode = depositoryService.findDepositoryById(ObjectFormatUtil.toInteger(depositoryId));
@ -710,8 +710,10 @@ public class PageController {
if (inventory.size() < 1) {
mv.addObject("materialById", new Material());
} else {
materialById = inventory.get(0);
mv.addObject("materialById", materialById);
inventoryP = inventory.get(0);
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(inventoryP.getMid());
inventoryP.setSplitInfoList(splitInfoByMid);
mv.addObject("materialById", inventoryP);
}
}
return mv;

11
src/main/java/com/dreamchaser/depository_manage/controller/PlaceController.java

@ -210,13 +210,12 @@ public class PlaceController {
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString());
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
List<PlaceP> placeList = new ArrayList<>();
for (int i = 0; i < depositoryByAdminorg.size(); i++) {
Depository depository = depositoryByAdminorg.get(i);
for (Depository depository : depositoryByAdminorg) {
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(mid, depository.getId());
for (int j = 0; j < placeByMidAndDid.size(); j++) {
int index = placeList.indexOf(placeByMidAndDid.get(j));
if(index == -1){
placeList.add(placeByMidAndDid.get(j));
for (PlaceP placeP : placeByMidAndDid) {
int index = placeList.indexOf(placeP);
if (index == -1) {
placeList.add(placeP);
}
}
}

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

@ -204,7 +204,7 @@
)
</insert>
<insert id="addMaterialOnPlace">
<insert id="addMaterialOnPlace" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into materialandplace(id,mid,pid,quantity)
values (
#{id},

4
src/main/java/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.xml

@ -95,10 +95,10 @@
<include refid="splitInventoryAllColumns"/>
from `split_inventory` si
where 1 = 1
<if test="iid != null and iid != ''">
<if test="iid != null ">
and si.iid = #{iid}
</if>
<if test="sid != null and sid != ''">
<if test="sid != null ">
and si.sid = #{sid}
</if>
</select>

15
src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java

@ -1,6 +1,7 @@
package com.dreamchaser.depository_manage.service;
import com.dreamchaser.depository_manage.entity.Inventory;
import com.dreamchaser.depository_manage.entity.MaterialAndPlace;
import com.dreamchaser.depository_manage.entity.SplitInfo;
import com.dreamchaser.depository_manage.entity.SplitInventory;
import com.dreamchaser.depository_manage.pojo.SplitInfoP;
@ -114,13 +115,13 @@ public interface SplitUnitService {
* 获取当前拆单与基础拆单之间的库存总额(当前拆单记录为-1是全部库存是使用)
*
* @param splitInfoId 当前拆单记录Id
* @param inventory 库存记录
* @param materialAndPlace 库存记录
* @param baseSplitInfoId 基础拆单记录Id
* @param saveQuantity 最终返回值
* @param allQuantityFlag 用于标志是否获取全部库存
* @return
*/
int findAllInventoryForSplitInfo(Integer splitInfoId, Inventory inventory, Integer baseSplitInfoId, int saveQuantity, boolean allQuantityFlag);
int findAllInventoryForSplitInfo(Integer splitInfoId, MaterialAndPlace materialAndPlace, Integer baseSplitInfoId, int saveQuantity, boolean allQuantityFlag);
/**
* 根据库存id与拆单记录id获取对应拆单库存处理记录
@ -131,6 +132,16 @@ public interface SplitUnitService {
SplitInventory findSplitInventoryByIidAndSid(Integer Iid,Integer sid);
/**
* 用于拆单库存处理记录的修改
*
* @param splitInfo 对应拆单记录
* @param quantity 修改数目
* @param map 入库条件
* @param inQuantity 最终入库数量
*/
void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity, SplitInfo baseSplitInfo);
/**
* 根据父级查询拆单记录
* @param parentId 待查询父级

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

@ -106,7 +106,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
//构造单号
String code = createCode(depositoryRecordById.getDname(), "InOrderNumber", "in", "");
Double quantity = Double.parseDouble((String) map.get("quantity"));
Double price = Double.parseDouble((String) map.get("price"));
double price = Double.parseDouble((String) map.get("price"));
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
// 根据物料id查询物料
Material material = materialMapper.findMaterialById(mid);
@ -115,11 +115,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
return 0;
}
// 获取当前填写的生产日期
Long producedDate = Long.valueOf(0);
long producedDate = 0L;
if (map.containsKey("producedDate")) {
Object s = map.get("producedDate");
if (s == null || "".equals(s.toString())) {
producedDate = Long.valueOf(0);
producedDate = 0L;
} else {
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString());
}
@ -564,10 +564,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
insertProducedDate.put("inid", InId);
insertProducedDate.put("mid", newInMid);
if (map.containsKey("producedDate")) {
Long producedDate = Long.valueOf(0);
Long producedDate = 0L;
Object s = map.get("producedDate");
if (s == null || "".equals(s.toString())) {
producedDate = Long.valueOf(0);
producedDate = 0L;
} else {
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString());
insertProducedDate.put("producedDate", producedDate);
@ -854,6 +854,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("quantity", trueOut.toString());
map.put("applicantId", record.getApplicantId());
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
map.put("unit", applicationOutMinById.getUnit());
transferMaterial(map);
}
restResponse.setStatus(200);
@ -893,8 +894,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setData("");
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足"));
}
}
else {
} else {
// 如果是拆单后的出库
// 用于获取对应的拆单记录
@ -904,10 +904,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取对应拆单记录
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前出库物料所在库位的对应关系
Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("mid", inventory.getId());
paramForInventoryToPlace.put("pid", placeId);
// 获取当前物料所存放库位的数量
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace);
// 获取当前拆单库存
Map<String, Object> paramForSplitInventory = new HashMap<>();
paramForSplitInventory.put("sid", splitInfo.getId());
paramForSplitInventory.put("iid", inventory.getId());
paramForSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId());
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
@ -929,6 +935,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 修改库存处理记录
splitUnitMapper.updateSplitInventory(splitInventory);
// 如果是库存转移订单
Map<String, Object> map = new HashMap<>();
if (record.getIstransfer() == 1) {
map.put("quantity", trueOut.toString());
map.put("applicantId", record.getApplicantId());
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
map.put("unit", applicationOutMinById.getUnit());
transferMaterial(map);
}
// 进行子订单的相关处理
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent);
@ -966,7 +982,20 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前父级拆单记录
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoById.getParentId());
restResponse = updateSplitInventoryInfo(parentSplitInfo, inventory, trueOut, surplus, splitInfo);
restResponse = updateOutSplitInventoryInfo(parentSplitInfo, placeAndMaterialByMidAndPid, trueOut, surplus, splitInfo);
// 如果成功出库
if (restResponse.getStatus() == 200) {
Map<String, Object> map = new HashMap<>();
if (record.getIstransfer() == 1) {
map.put("quantity", trueOut.toString());
map.put("applicantId", record.getApplicantId());
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
map.put("unit", applicationOutMinById.getUnit());
transferMaterial(map);
}
}
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent);
} else {
@ -1043,6 +1072,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + trueOut);
splitUnitMapper.updateSplitInventory(splitInventory);
// 如果是库存转移订单
if (record.getIstransfer() == 1) {
map.put("quantity", trueOut.toString());
map.put("applicantId", record.getApplicantId());
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
map.put("unit", applicationOutMinById.getUnit());
transferMaterial(map);
}
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent);
restResponse.setStatus(200);
@ -1184,7 +1223,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 添加拆单库存处理记录
Map<String, Object> insertSplitInventory = new HashMap<>();
insertSplitInventory.put("sid", splitInfo.getId());
insertSplitInventory.put("iid", inventory.getId());
insertSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId());
insertSplitInventory.put("outQuantity", trueOut);
insertSplitInventory.put("inQuantity", 0);
insertSplitInventory.put("saveQuantity", splitInfo.getQuantity() - residue_realQuantity);
@ -1223,19 +1262,19 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* 用于有父级拆单记录的出库处理
*
* @param splitInfo 父级拆单记录
* @param inventory 当前库存记录
* @param materialAndPlace 当前库存记录
* @param quantity 当前出库总量
* @param nowQuantity 当前未出库数量
* @param realSplitInfo 实际出库的拆单记录
* @return
*/
RestResponse updateSplitInventoryInfo(SplitInfo splitInfo, Inventory inventory, int quantity, int nowQuantity, SplitInfo realSplitInfo) {
RestResponse updateOutSplitInventoryInfo(SplitInfo splitInfo, MaterialAndPlace materialAndPlace, int quantity, int nowQuantity, SplitInfo realSplitInfo) {
// 定义返回值
RestResponse restResponse = new RestResponse();
// 用于获取当前拆单记录对应的拆单库存记录
Map<String, Object> paramForSplitInventory = new HashMap<>();
paramForSplitInventory.put("sid", splitInfo.getId());
paramForSplitInventory.put("iid", inventory.getId());
paramForSplitInventory.put("iid", materialAndPlace.getId());
SplitInventory splitInventoryForSplitInfo = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
// 获取当前拆单记录与实际出库拆单之间的进制
int parentScale = splitUnitService.findSplitInfoScaleQuantity(realSplitInfo, splitInfo.getId());
@ -1268,7 +1307,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 如果当前库存拆单记录的库存不能满足需要
// 获取当前物料的库存
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, inventory, realSplitInfo.getId(), 0, true);
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, materialAndPlace, realSplitInfo.getId(), 0, true);
// 判断当前所有库存是否可以满足需求
if (allInventoryForSplitInfo >= nowQuantity) {
// 如果当前库存数可以满足需求
@ -1350,7 +1390,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 如果当前还有父级
// 进行递归
RestResponse restResponse1 = updateSplitInventoryInfo(parentSplitInfo, inventory, quantity, nowQuantity, splitInfo);
RestResponse restResponse1 = updateOutSplitInventoryInfo(parentSplitInfo, materialAndPlace, quantity, nowQuantity, splitInfo);
// 获取其父级减少与实际出库的拆单记录的数量
Object data = restResponse1.getData();
// 计算当前与最底层的进制
@ -1391,7 +1431,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前拆单单位与顶级之间的进制
int splitInfoQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
// 获取所有当前单位的拆单库存
realQuantity = inventory.getQuantity() * splitInfoQuantity + realQuantity;
realQuantity = materialAndPlace.getQuantity() * splitInfoQuantity + realQuantity;
if (realQuantity > nowQuantity) {
// 如果可以出库
@ -1401,13 +1441,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 计算库存需要减少的数量
int inventory_quantity = (int) Math.ceil((double) residue_quantity / splitInfoQuantity);
// 获取对应的库存
Inventory inventory = materialMapper.findInventoryById(materialAndPlace.getMid());
// 重新设置库存数量
materialAndPlace.setQuantity(materialAndPlace.getQuantity() - inventory_quantity);
inventory.setQuantity(inventory.getQuantity() - inventory_quantity);
// 重新设置总额
inventory.setAmounts(inventory.getAmounts() - inventory_quantity * inventory.getPrice());
if (Integer.compare(inventory.getQuantity(), 0) != 0) {
if (Integer.compare(materialAndPlace.getQuantity(), 0) != 0) {
// 重新计算单价
BigDecimal decimal = BigDecimal.valueOf(inventory.getAmounts() / inventory.getQuantity());
Double price = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
@ -1415,6 +1459,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
}
// 修改库存数量
materialMapper.updateInventory(inventory);
placeMapper.updateMaterialAndPlace(materialAndPlace);
} else {
@ -1434,7 +1479,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 计算库存减少的数目
int surplus_redundant = (int) Math.ceil(nowQuantity / splitInfoScaleQuantityForAll);
// 获取对应的库存
Inventory inventory = materialMapper.findInventoryById(materialAndPlace.getMid());
// 设置当前库存数量
materialAndPlace.setQuantity(materialAndPlace.getQuantity() - surplus_redundant);
inventory.setQuantity(inventory.getQuantity() - surplus_redundant);
// 设置当前总额
inventory.setAmounts(inventory.getPrice() * inventory.getQuantity());
@ -1446,6 +1495,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
}
// 修改库存数量
materialMapper.updateInventory(inventory);
placeMapper.updateMaterialAndPlace(materialAndPlace);
restResponse.setData(surplus_redundant);
}
@ -2349,28 +2399,34 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取子订单
ApplicationOutRecordMin recordMin = depositoryRecordMapper.findApplicationOutMinById(minRecordId);
// 获取转移详情
TransferRecord transferRecor = transferRecordMapper.findTransferRecordById(recordMin.getTransferId());
Integer mid = transferRecor.getMid();
// 获取库存信息
TransferRecord transferRecord = transferRecordMapper.findTransferRecordById(recordMin.getTransferId());
Integer mid = transferRecord.getMid();
// 获取转出时库存信息
Inventory material = materialMapper.findInventoryById(mid);
param.put("mcode", material.getCode());
param.put("depositoryId", transferRecor.getToId());
List<Inventory> materiallist = materialMapper.findInventory(param);
if (materiallist.size() > 0) {
param.put("depositoryId", transferRecord.getToId());
List<Inventory> inventories = materialMapper.findInventory(param);
// 获取当前处理的单位
String unit = recordMin.getUnit();
map.put("mid", material.getMid());
map.put("depositoryId", transferRecord.getToId());
map.put("placeId", transferRecord.getToPlaceId());
if ("-1".equals(unit)) {
// 如果是基础单位
if (inventories.size() > 0) {
// 如果在该仓库
map.put("price", material.getPrice().toString());
map.put("depositoryId", transferRecor.getToId());
map.put("placeId", transferRecor.getToPlaceId());
map.put("mid", material.getMid());
applicationInPlace(map);
} else {
// 如果不在该仓库,插入一条新记录
Map<String, Object> insert = new HashMap<>();
Material materialById = materialMapper.findMaterialById(material.getMid());
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity"));
insert.put("depositoryId", transferRecor.getToId());
insert.put("depositoryId", transferRecord.getToId());
insert.put("price", material.getPrice());
insert.put("mid", materialById.getId());
insert.put("mid", material.getMid());
insert.put("quantity", quantity);
insert.put("amounts", quantity * material.getPrice());
insert.put("depositoryCode", material.getDepositoryCode());
@ -2378,21 +2434,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
materialMapper.insertInventory(insert);
// 查询该记录
/*Integer id =ObjectFormatUtil.toInteger(insert.get("id"));
Material byId = materialMapper.findMaterialById(id);
*/
Map<String, Object> temp = new HashMap<>();
temp.put("mcode", materialById.getCode());
temp.put("depositoryId", transferRecor.getToId());
temp.put("mname", materialById.getMname());
List<Inventory> inventoryList = materialMapper.findInventory(temp);
// 获取该库存记录
Inventory inventory = inventoryList.get(0);
Inventory inventory = materialMapper.findInventoryById(ObjectFormatUtil.toInteger(insert.get("id")));
Map<String, Object> fromPlaceTemp = new HashMap<>();
Map<String, Object> toPlaceTemp = new HashMap<>();
// 转入库位
Place toPlace = placeMapper.findPlaceById(transferRecor.getToPlaceId());
Place toPlace = placeMapper.findPlaceById(transferRecord.getToPlaceId());
toPlace.setQuantity(toPlace.getQuantity() + quantity);
placeMapper.UpdatePlace(toPlace); // 修改转入库位额度
@ -2408,9 +2456,328 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
placeMapper.updateMaterialAndPlace(toMaterialAndPlace);
}
}
}
else {
// 如果是拆单单位
// 用于获取当前拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid", material.getMid());
paramForSplitInfo.put("newUnit", unit);
// 获取当前拆单记录
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前拆单与顶级之间的进制
int scaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
// 获取当前转移的数量
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity"));
if (inventories.size() > 0) {
// 如果在转入的仓库中存在该物料的库存记录
// 获取当前库存记录
Inventory inventory = inventories.get(0);
// 用于查询物料所在库位
Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("pid", transferRecord.getToPlaceId());
paramForInventoryToPlace.put("mid", inventory.getId());
// 获取当前物料是否存在于当前库位
MaterialAndPlace placeAndMaterial = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace);
if (placeAndMaterial != null) {
// 如果存在于当前库位
// 用于查询当前拆单记录的库存记录
Map<String, Object> paramForSplitInventory = new HashMap<>();
paramForSplitInventory.put("sid", splitInfo.getId());
paramForSplitInventory.put("iid", placeAndMaterial.getId());
// 获取当前拆单记录的库存记录
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
if (splitInventory != null) {
// 如果存在该库存记录
if (splitInfo.getQuantity() >= splitInventory.getSaveQuantity() + quantity) {
// 如果没达到当前进制数量
// 设置当前转移后的库存数量
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + quantity);
// 设置当前增加的数量
splitInventory.setInQuantity(splitInventory.getInQuantity() + quantity);
// 修改当前拆单库存处理记录
splitUnitMapper.updateSplitInventory(splitInventory);
} else {
// 如果大于当前进制数量
// 计算处理数量(下取整)
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double) splitInfo.getQuantity()));
// 最终存储到拆单处理的数量
double saveQuantity = quantity - disposeQuantity * splitInfo.getQuantity();
// 最终存储数量
int realQuantity = (int) Math.round(saveQuantity) + splitInventory.getSaveQuantity();
if (realQuantity >= splitInfo.getQuantity()) {
// 如果当前入库的数量大于拆单规定的进制数量
// 计算要进的数目
int quantity_in = (realQuantity / splitInfo.getQuantity());
// 更新处理数量
disposeQuantity += quantity_in;
// 拆单库存实际入库的数量
realQuantity = realQuantity - quantity_in * splitInfo.getQuantity();
}
// 设置当前计量单位的库存
splitInventory.setSaveQuantity(realQuantity);
// 更新当前数据
splitUnitMapper.updateSplitInventory(splitInventory);
if (disposeQuantity != 0) {
// 用于更改库存的数量
map.put("quantity", String.valueOf(disposeQuantity));
} else {
map.put("quantity", "0");
}
// 进行修改当前拆单库存数量
map.put("newInMid", placeAndMaterial.getId());
map.put("price", material.getPrice() / scaleQuantity);
// 实际入库数量
map.put("realQuantity", quantity.toString());
if (splitInfo.getParentId() != null) {
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId());
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterial.getId(), map, quantity, splitInfo);
} else {
applicationInPlace(map);
map.remove("id");
}
}
} else {
// 如果不存在该库存记录
// 用于插入拆单库存记录
Map<String, Object> insertForSplitInventory = new HashMap<>();
insertForSplitInventory.put("iid", placeAndMaterial.getId());
insertForSplitInventory.put("sid", splitInfo.getId());
insertForSplitInventory.put("outQuantity", 0);
if (quantity < splitInfo.getQuantity()) {
// 如果当前转移数量小于进制数量
// 设置入库数量
insertForSplitInventory.put("inQuantity", quantity);
// 设置当前库存数
insertForSplitInventory.put("saveQuantity", quantity);
splitUnitMapper.addSplitInventory(insertForSplitInventory);
} else {
// 如果不小于
// 计算处理数量(下取整)
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double) splitInfo.getQuantity()));
// 最终存储到拆单处理的数量
double saveQuantity = quantity - disposeQuantity * splitInfo.getQuantity();
// 最终存储数量
int realQuantity = (int) Math.round(saveQuantity);
if (realQuantity >= splitInfo.getQuantity()) {
// 如果当前入库的数量大于拆单规定的进制数量
// 计算要进的数目
int quantity_in = (realQuantity / splitInfo.getQuantity());
// 更新处理数量
disposeQuantity += quantity_in;
// 拆单库存实际入库的数量
realQuantity = realQuantity - quantity_in * splitInfo.getQuantity();
}
// 设置入库数量
insertForSplitInventory.put("inQuantity", 0);
// 设置当前计量单位的库存
insertForSplitInventory.put("saveQuantity", realQuantity);
// 先添加一条拆单库存记录
splitUnitMapper.addSplitInventory(insertForSplitInventory);
if (disposeQuantity != 0) {
// 用于更改库存的数量
map.put("quantity", String.valueOf(disposeQuantity));
} else {
map.put("quantity", "0");
}
// 进行修改当前拆单库存数量
map.put("newInMid", placeAndMaterial.getId());
map.put("price", material.getPrice() / scaleQuantity);
// 实际入库数量
map.put("realQuantity", quantity.toString());
if (splitInfo.getParentId() != null) {
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId());
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterial.getId(), map, quantity, splitInfo);
} else {
applicationInPlace(map);
map.remove("id");
}
}
}
} else {
// 如果不存在于当前库位
// 用于添加一条物料于库位的对应关系
Map<String, Object> insertForMaterialAndPlace = new HashMap<>();
insertForMaterialAndPlace.put("mid", inventory.getId());
insertForMaterialAndPlace.put("pid", transferRecord.getToPlaceId());
insertForMaterialAndPlace.put("quantity", 0);
// 先添加一条记录
placeMapper.addMaterialOnPlace(insertForMaterialAndPlace);
// 用于插入拆单库存记录
Map<String, Object> insertForSplitInventory = new HashMap<>();
insertForSplitInventory.put("iid", insertForMaterialAndPlace.get("id"));
insertForSplitInventory.put("sid", splitInfo.getId());
insertForSplitInventory.put("outQuantity", 0);
if (quantity < splitInfo.getQuantity()) {
// 如果当前转移数量小于进制数量
// 设置入库数量
insertForSplitInventory.put("inQuantity", quantity);
// 设置当前库存数
insertForSplitInventory.put("saveQuantity", quantity);
splitUnitMapper.addSplitInventory(insertForSplitInventory);
} else {
// 如果不小于
map.put("price", material.getPrice() / scaleQuantity);
updateSplitInventoryForMoreScale(material, map, splitInfo, quantity, insertForMaterialAndPlace, insertForSplitInventory);
}
}
} else {
// 如果在转入的仓库中不存在该物料的库存记录
// 用于添加一条库存记录
Map<String, Object> insertForInventory = new HashMap<>();
insertForInventory.put("depositoryId", transferRecord.getToId());
insertForInventory.put("price", material.getPrice());
insertForInventory.put("mid", material.getMid());
insertForInventory.put("quantity", 0);
insertForInventory.put("amounts", 0);
insertForInventory.put("depositoryCode", material.getDepositoryCode());
insertForInventory.put("producedDate", material.getProducedDate());
// 添加一条库存记录
materialMapper.insertInventory(insertForInventory);
// 用于添加物料与库位的对应关系
Map<String, Object> insertForMaterialAndPlace = new HashMap<>();
insertForMaterialAndPlace.put("mid", insertForInventory.get("id"));
insertForMaterialAndPlace.put("pid", transferRecord.getToPlaceId());
insertForMaterialAndPlace.put("quantity", 0);
// 添加一条物料与库位的对应关系记录
placeMapper.addMaterialOnPlace(insertForMaterialAndPlace);
// 用于插入拆单库存记录
Map<String, Object> insertForSplitInventory = new HashMap<>();
insertForSplitInventory.put("iid", insertForMaterialAndPlace.get("id"));
insertForSplitInventory.put("sid", splitInfo.getId());
insertForSplitInventory.put("outQuantity", 0);
if (quantity < splitInfo.getQuantity()) {
// 如果当前转移数量小于进制数量
// 设置入库数量
insertForSplitInventory.put("inQuantity", quantity);
// 设置当前库存数
insertForSplitInventory.put("saveQuantity", quantity);
splitUnitMapper.addSplitInventory(insertForSplitInventory);
} else {
// 如果不小于
map.put("price", material.getPrice() / scaleQuantity);
updateSplitInventoryForMoreScale(material, map, splitInfo, quantity, insertForMaterialAndPlace, insertForSplitInventory);
}
}
}
}
/**
* 用于处理超出进制的拆单库存处理记录
*
* @param material 转移的物料
* @param map 存储的部分数据
* @param splitInfo 当前拆单记录
* @param quantity 超出的数量
* @param insertForMaterialAndPlace 用于添加物料与库位对应关系的数据
* @param insertForSplitInventory 用于添加一条新的拆单库存处理记录
*/
void updateSplitInventoryForMoreScale(Inventory material, Map<String, Object> map, SplitInfo splitInfo, Integer quantity, Map<String, Object> insertForMaterialAndPlace, Map<String, Object> insertForSplitInventory) {
// 计算处理数量(下取整)
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double) splitInfo.getQuantity()));
// 最终存储到拆单处理的数量
double saveQuantity = quantity - disposeQuantity * splitInfo.getQuantity();
// 最终存储数量
int realQuantity = (int) Math.round(saveQuantity);
if (realQuantity >= splitInfo.getQuantity()) {
// 如果当前入库的数量大于拆单规定的进制数量
// 计算要进的数目
int quantity_in = (realQuantity / splitInfo.getQuantity());
// 更新处理数量
disposeQuantity += quantity_in;
// 拆单库存实际入库的数量
realQuantity = realQuantity - quantity_in * splitInfo.getQuantity();
}
// 设置入库数量
insertForSplitInventory.put("inQuantity", 0);
// 设置当前计量单位的库存
insertForSplitInventory.put("saveQuantity", realQuantity);
// 先添加一条拆单库存记录
splitUnitMapper.addSplitInventory(insertForSplitInventory);
if (disposeQuantity != 0) {
// 用于更改库存的数量
map.put("quantity", String.valueOf(disposeQuantity));
} else {
map.put("quantity", "0");
}
// 进行修改当前拆单库存数量
map.put("newInMid", insertForMaterialAndPlace.get("id"));
// 实际入库数量
map.put("realQuantity", quantity.toString());
if (splitInfo.getParentId() != null) {
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId());
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(insertForMaterialAndPlace.get("id")), map, quantity, splitInfo);
} else {
applicationInPlace(map);
map.remove("id");
}
}
/**
* 根据id修改仓库调度记录

64
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java

@ -263,8 +263,8 @@ public class MaterialServiceImpl implements MaterialService {
Integer mid = list.get(i).getId();
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(mid, depositoryId);
StringBuilder placeCode = new StringBuilder();
for (int j = 0; j < placeByMidAndDid.size(); j++) {
placeCode.append(placeByMidAndDid.get(j).getCode()).append(" ");
for (PlaceP placeP : placeByMidAndDid) {
placeCode.append(placeP.getCode()).append(" ");
}
if (depositoryId != null) {
Depository depositoryRecordById = depositoryMapper.findDepositoryById(depositoryId);
@ -592,25 +592,29 @@ public class MaterialServiceImpl implements MaterialService {
m.setProducedDate(DateUtil.TimeStampToDateTimeForDay(producedDate));
}
// 设置当前物料保质期的具体时间
Long calcShelfLife = Long.valueOf(0);
Long calcShelfLife = 0L;
String currentDate = DateUtil.getCurrentDate();
// 获取当天时间
Long nowDay = DateUtil.DateTimeByDayToTimeStamp(currentDate);
long nowDay = DateUtil.DateTimeByDayToTimeStamp(currentDate);
Long life = inventory.getShelfLife();
if (life != null) {
String shelfLife = String.valueOf(life);
String dateType = shelfLife.substring(0, 1);
String dateTime = shelfLife.substring(1);
if ("1".equals(dateType)) {
switch (dateType) {
case "1":
m.setShelfLife(dateTime + "年");
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * 365 * DateUtil.dayTime;
} else if ("2".equals(dateType)) {
break;
case "2":
m.setShelfLife(dateTime + "月");
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * 30 * DateUtil.dayTime;
} else if ("3".equals(dateType)) {
break;
case "3":
m.setShelfLife(dateTime + "天");
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * DateUtil.dayTime;
break;
}
// 获取当前没有使用完成的物料对应的生产日期对应
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialMapper.findMaterialAndProducedDateByMid(m.getId());
@ -627,23 +631,41 @@ public class MaterialServiceImpl implements MaterialService {
m.setTypeName(materialTypeByOldId.getTname());
m.setTypeId(materialTypeByOldId.getOldId());
m.setWarningCount(warningCount);
// 获取当前是否存在拆单处理记录
List<SplitInventory> splitInventoryList = splitUnitMapper.findSplitInventoryByIid(m.getId());
if (splitInventoryList.size() > 0) {
// 如果存在拆单库存处理记录
// 查询当前物料在该仓库中的库位位置
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(m.getId(), m.getDepositoryId());
Map<String,Integer> splitInventoryForUnit = new HashMap<>();
// 获取拆单信息
// 获取拆单信息对应库存
StringBuilder showQuantity = new StringBuilder();
//定义总额
double amounts = 0.0;
if (Integer.compare(m.getQuantity(), 0) != 0) {
showQuantity.append(m.getUnit()).append(":").append(m.getQuantity());
showQuantity.append(m.getUnit()).append(":").append(m.getQuantity()).append(" ");
}
for (PlaceP place:
placeByMidAndDid) {
// 获取当前具体数据
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(place.getId(), m.getId());
// 获取当前是否存在拆单处理记录
List<SplitInventory> splitInventoryList = splitUnitMapper.findSplitInventoryByIid(placeAndMaterialByMidAndPid.getId());
if (splitInventoryList.size() > 0) {
// 如果存在拆单库存处理记录
for (SplitInventory splitInventory : splitInventoryList) {
SplitInfo splitInfo = splitUnitMapper.findSplitInfoById(splitInventory.getSid());
if (Integer.compare(splitInventory.getSaveQuantity(), 0) != 0) {
showQuantity.append(splitInfo.getNewUnit()).append(":").append(splitInventory.getSaveQuantity()).append(" ");
if(splitInventoryForUnit.containsKey(splitInfo.getNewUnit())){
// 如果当前存在该拆单类型的记录
// 更新当前类型数据
splitInventoryForUnit.put(splitInfo.getNewUnit(),splitInventoryForUnit.get(splitInfo.getNewUnit())+splitInventory.getSaveQuantity());
}else{
// 如果不存在,则新增
splitInventoryForUnit.put(splitInfo.getNewUnit(),splitInventory.getSaveQuantity());
}
// 计算拆单后的单价
BigDecimal bigDecimal = BigDecimal.valueOf(inventory.getPrice() / splitInfo.getQuantity());
double split_price = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
@ -651,13 +673,15 @@ public class MaterialServiceImpl implements MaterialService {
}
}
}
}
// 设置新总额
m.setAmounts(m.getAmounts() + amounts);
m.setShowQuantity(showQuantity.toString());
} else {
m.setShowQuantity(m.getUnit() + ":" + m.getQuantity());
// 获取当前各拆单信息对应的库存
for (Map.Entry<String, Integer> entry : splitInventoryForUnit.entrySet()) {
showQuantity.append(entry.getKey()).append(":").append(entry.getValue()).append(" ");
}
m.setShowQuantity(showQuantity.toString());
result.add(m);
}
return result;

172
src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java

@ -101,16 +101,27 @@ public class SplitUnitServiceImpl implements SplitUnitService {
SplitInventory splitInventory = null;
// 定义对应的库存记录
Inventory inventory = null;
// 定义对应库存所在库位
MaterialAndPlace placeAndMaterialByMidAndPid = null;
// 用于存储拆单库存处理操作的数据
Map<String, Object> paramForInsertSplitInventory = new HashMap<>();
paramForInsertSplitInventory.put("sid", splitInfoForUnit.getId());
if (iid != null) {
paramForInsertSplitInventory.put("iid", iid);
// 查询当前库存是否有该拆单的处理记录
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
// 获取对应的库存记录
inventory = materialMapper.findInventoryById(iid);
Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("pid", map.get("placeId"));
paramForInventoryToPlace.put("mid", inventory.getId());
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace);
if (placeAndMaterialByMidAndPid != null) {
paramForInsertSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId());
// 查询当前库存是否有该拆单的处理记录
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
}
} else {
Map<String, Object> param = new HashMap<>();
param.put("depositoryId", map.get("depositoryId"));
@ -120,12 +131,20 @@ public class SplitUnitServiceImpl implements SplitUnitService {
if (inventoryList.size() > 0) {
inventory = inventoryList.get(0);
paramForInsertSplitInventory.put("iid", inventory.getId());
// 用于查找该库存对应库位
Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("pid", map.get("placeId"));
paramForInventoryToPlace.put("mid", inventory.getId());
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace);
if (placeAndMaterialByMidAndPid != null) {
paramForInsertSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId());
// 查询当前库存是否有该拆单的处理记录
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
}
}
}
// 获取要操作的数量
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity"));
@ -176,12 +195,13 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("realQuantity", quantity.toString());
if (splitInfoForUnit.getParentId() != null) {
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoForUnit.getParentId());
updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, inventory.getId(), map, quantity.intValue(),splitInfoForUnit);
updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterialByMidAndPid.getId(), map, quantity.intValue(), splitInfoForUnit);
} else {
Double price = Double.parseDouble((String) map.get("price"));
double price = Double.parseDouble((String) map.get("price"));
price = price * findSplitInfoScaleQuantity(splitInfoForUnit, -1);
map.put("price", price.toString());
map.put("price", Double.toString(price));
depositoryRecordService.applicationInPlace(map);
map.remove("id");
}
@ -198,49 +218,56 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("quantity", "0");
}
if (disposeQuantity > splitInfoForUnit.getQuantity()) {
//如果当前处理数量大于设置的进制数量
// 实际入库数量
map.put("realQuantity", quantity.toString());
if (disposeQuantity > splitInfoForUnit.getQuantity()) {
//如果当前处理数量大于设置的进制数量
if (parentId != null) {
// 如果该记录有父级拆单
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId);
if (inventory != null) {
updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), inventory.getId(), map, quantity.intValue(),splitInfoForUnit);
if (placeAndMaterialByMidAndPid != null) {
updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), placeAndMaterialByMidAndPid.getId(), map, quantity.intValue(), splitInfoForUnit);
} else {
Double price = Double.parseDouble((String) map.get("price"));
double price = Double.parseDouble((String) map.get("price"));
price = price * findSplitInfoScaleQuantity(splitInfoForUnit, -1);
map.put("price", price.toString());
map.put("price", Double.toString(price));
result += depositoryRecordService.applicationInPlace(map);
updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), ObjectFormatUtil.toInteger(map.get("newInMid")), map, quantity.intValue(),splitInfoForUnit);
map.remove("id");
Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("mid", map.get("newInMid"));
paramForInventoryToPlace.put("pid", map.get("placeId"));
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace);
updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), placeAndMaterialByMidAndPid.getId(), map, quantity.intValue(), splitInfoForUnit);
}
} else {
Double price = Double.parseDouble((String) map.get("price"));
double price = Double.parseDouble((String) map.get("price"));
price = price * findSplitInfoScaleQuantity(splitInfoForUnit, -1);
map.put("price", price.toString());
map.put("price", Double.toString(price));
result += depositoryRecordService.applicationInPlace(map);
map.remove("id");
}
} else {
}
else {
// 如果不大于设置的进制数量
paramForInsertSplitInventory.put("inQuantity", quantity);
paramForInsertSplitInventory.put("outQuantity", 0);
paramForInsertSplitInventory.put("saveQuantity", saveQuantity);
if (inventory != null) {
if (placeAndMaterialByMidAndPid != null) {
// 如果有库存记录
paramForInsertSplitInventory.put("iid", inventory.getId());
paramForInsertSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId());
} else {
// 如果没有库存记录
// 插入一条库存记录
Double price = Double.parseDouble((String) map.get("price"));
double price = Double.parseDouble((String) map.get("price"));
price = price * findSplitInfoScaleQuantity(splitInfoForUnit, -1);
map.put("price", price.toString());
map.put("price", Double.toString(price));
if (parentId != null) {
@ -248,21 +275,26 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 先插入一条库存记录用于后续操作
map.put("quantity", "0");
result += depositoryRecordService.applicationInPlace(map);
depositoryRecordService.applicationInPlace(map);
map.remove("id");
} else {
// 如果没有父级
result += depositoryRecordService.applicationInPlace(map);
depositoryRecordService.applicationInPlace(map);
map.remove("id");
}
paramForInsertSplitInventory.put("iid", map.get("newInMid"));
Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("mid", map.get("newInMid"));
paramForInventoryToPlace.put("pid", map.get("placeId"));
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace);
paramForInsertSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId());
}
splitUnitMapper.addSplitInventory(paramForInsertSplitInventory);
result += splitUnitMapper.addSplitInventory(paramForInsertSplitInventory);
if (parentId != null) {
// 获取父级
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoForUnit.getParentId());
updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(map.get("newInMid")), map, quantity.intValue(),splitInfoForUnit);
updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterialByMidAndPid.getId(), map, quantity.intValue(), splitInfoForUnit);
}
}
@ -277,6 +309,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 用于计算当前拆单单位与目标拆单单位之间的进率
*
* @param splitInfo 待查询拆单记录
* @param parentSplitInfoId 目标拆单单位
* @return
@ -310,13 +343,13 @@ public class SplitUnitServiceImpl implements SplitUnitService {
* 获取当前拆单与基础拆单之间的库存总额(当前拆单记录为-1是全部库存是使用)
*
* @param splitInfoId 当前拆单记录Id
* @param inventory 库存记录
* @param materialAndPlace 库存记录
* @param baseSplitInfoId 基础拆单记录Id
* @param saveQuantity 最终返回值
* @param allQuantityFlag 用于标志是否获取全部库存
* @return
*/
public int findAllInventoryForSplitInfo(Integer splitInfoId, Inventory inventory, Integer baseSplitInfoId, int saveQuantity, boolean allQuantityFlag) {
public int findAllInventoryForSplitInfo(Integer splitInfoId, MaterialAndPlace materialAndPlace, Integer baseSplitInfoId, int saveQuantity, boolean allQuantityFlag) {
if (allQuantityFlag) {
// 用于标志是否第一次计算
@ -327,7 +360,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 获取当前基础单位的库存
Map<String, Object> paramForSplitInventory = new HashMap<>();
paramForSplitInventory.put("iid", inventory.getId());
paramForSplitInventory.put("iid", materialAndPlace.getId());
// 如果当前获取的为对应基础单位的所有库存
// 如果是第一次计算
@ -340,57 +373,56 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 当前基础单位的库存
SplitInventory baseSplitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
if(baseSplitInventory != null) {
if (baseSplitInventory != null) {
saveQuantity += baseSplitInventory.getSaveQuantity();
}
}
if(Integer.compare(-1,splitInfoId) != 0){
if (Integer.compare(-1, splitInfoId) != 0) {
flag = true;
// 获取当前记录的子记录
SplitInfo splitInfoByParentId = splitUnitMapper.findSplitInfoByParentId(splitInfoId);
paramForSplitInventory.put("sid",splitInfoId);
paramForSplitInventory.put("sid", splitInfoId);
SplitInventory splitInventoryByIidAndSid = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
if(splitInventoryByIidAndSid != null){
if (splitInventoryByIidAndSid != null) {
saveQuantity += splitInventoryByIidAndSid.getSaveQuantity() * splitInfoByParentId.getQuantity();
}
}
if(baseSplitInfo.getParentId() != null && !flag){
if (baseSplitInfo.getParentId() != null && !flag) {
// 如果有父级且是第一次
// 获取其父级
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(baseSplitInfo.getParentId());
return findAllInventoryForSplitInfo(parentSplitInfo.getId(),inventory,baseSplitInfoId,saveQuantity,allQuantityFlag);
}else{
if(flag){
return findAllInventoryForSplitInfo(parentSplitInfo.getId(), materialAndPlace, baseSplitInfoId, saveQuantity, allQuantityFlag);
} else {
if (flag) {
// 如果不是第一次
// 获取当前的拆单记录
SplitInfo splitInfo = splitUnitMapper.findSplitInfoById(splitInfoId);
if(splitInfo.getParentId() != null){
if (splitInfo.getParentId() != null) {
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId());
return findAllInventoryForSplitInfo(parentSplitInfo.getId(),inventory,baseSplitInfoId,saveQuantity,allQuantityFlag);
}else{
return findAllInventoryForSplitInfo(parentSplitInfo.getId(), materialAndPlace, baseSplitInfoId, saveQuantity, allQuantityFlag);
} else {
int splitInfoScaleQuantity = findSplitInfoScaleQuantity(baseSplitInfo, -1);
return saveQuantity + inventory.getQuantity() * splitInfoScaleQuantity;
return saveQuantity + materialAndPlace.getQuantity() * splitInfoScaleQuantity;
}
}else{
} else {
int splitInfoScaleQuantity = findSplitInfoScaleQuantity(baseSplitInfo, -1);
return saveQuantity + inventory.getQuantity() * splitInfoScaleQuantity;
return saveQuantity + materialAndPlace.getQuantity() * splitInfoScaleQuantity;
}
}
}
else {
} else {
// 如果不是获取所有库存
// 获取当前基础单位
SplitInfo baseSplitInfo = splitUnitMapper.findSplitInfoById(baseSplitInfoId);
// 获取当前基础单位的库存
Map<String, Object> paramForSplitInventory = new HashMap<>();
paramForSplitInventory.put("iid", inventory.getId());
paramForSplitInventory.put("iid", materialAndPlace.getId());
// 如果当前获取的为对应基础单位的所有库存
if (Integer.compare(saveQuantity, 0) == 0) {
@ -412,9 +444,9 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 获取当前的子类
SplitInfo splitInfoByParentId = splitUnitMapper.findSplitInfoByParentId(splitInfoId);
if (splitInfoByParentId != null && Integer.compare(splitInfoByParentId.getId(),baseSplitInfoId) != 0) {
if (splitInfoByParentId != null && Integer.compare(splitInfoByParentId.getId(), baseSplitInfoId) != 0) {
// 如果有子类
return findAllInventoryForSplitInfo(splitInfoByParentId.getId(), inventory, baseSplitInfoId, saveQuantity, allQuantityFlag);
return findAllInventoryForSplitInfo(splitInfoByParentId.getId(), materialAndPlace, baseSplitInfoId, saveQuantity, allQuantityFlag);
} else {
// 如果没有
return saveQuantity;
@ -436,7 +468,6 @@ public class SplitUnitServiceImpl implements SplitUnitService {
Map<String, Object> param = new HashMap<>();
param.put("iid", Iid);
param.put("sid", sid);
return splitUnitMapper.findSplitInventoryByIidAndSid(param);
}
@ -458,8 +489,9 @@ public class SplitUnitServiceImpl implements SplitUnitService {
* @param quantity 修改数目
* @param map 入库条件
* @param inQuantity 最终入库数量
* @param baseSplitInfo 基础拆单记录
*/
private void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity,SplitInfo baseSplitInfo) {
public void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity, SplitInfo baseSplitInfo) {
// 获取当前拆单记录的父级拆单记录
@ -476,7 +508,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
int scale = splitInfo.getQuantity();
// 计算处理数量(下取整)
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double)scale));
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double) scale));
// 最终存储到拆单处理的数量
double saveQuantity = quantity - disposeQuantity * scale;
@ -505,33 +537,34 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 获取具体父级
SplitInfo splitInfoForParent = splitUnitMapper.findSplitInfoById(parentId);
updateSplitInfoSaveQuantity(splitInfoForParent, disposeQuantity, splitInventory.getIid(), map, inQuantity,baseSplitInfo);
updateSplitInfoSaveQuantity(splitInfoForParent, disposeQuantity, splitInventory.getIid(), map, inQuantity, baseSplitInfo);
} else {
// 如果为空
Double price = Double.parseDouble((String) map.get("price"));
double price = Double.parseDouble((String) map.get("price"));
price = price * findSplitInfoScaleQuantity(baseSplitInfo, -1);
map.put("price", price.toString());
map.put("price", Double.toString(price));
map.put("quantity", String.valueOf(disposeQuantity));
map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map);
map.remove("id");
}
}
else {
// 当前库存拆单记录与新入库的数目不大于预设的进制
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int)saveQuantity);
splitInventory.setInQuantity(splitInventory.getInQuantity() + (int)saveQuantity);
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int) saveQuantity);
splitInventory.setInQuantity(splitInventory.getInQuantity() + (int) saveQuantity);
splitUnitMapper.updateSplitInventory(splitInventory);
Double price = Double.parseDouble((String) map.get("price"));
double price = Double.parseDouble( map.get("price").toString());
price = price * findSplitInfoScaleQuantity(baseSplitInfo, -1);
map.put("price", price.toString());
map.put("price", Double.toString(price));
map.put("quantity", "0");
map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map);
map.remove("id");
}
} else {
}
else {
// 如果为空
Map<String, Object> paramForInsertSplitInventory = new HashMap<>();
@ -539,7 +572,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
paramForInsertSplitInventory.put("sid", splitInfo.getId());
paramForInsertSplitInventory.put("inQuantity", quantity);
paramForInsertSplitInventory.put("outQuantity", 0);
paramForInsertSplitInventory.put("iid", map.get("newInMid"));
paramForInsertSplitInventory.put("iid", iid);
if (quantity > splitInfo.getQuantity()) {
// 如果当前处理数量大于当前设置的进制数量
@ -556,22 +589,25 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 获取当前拆单记录的父级
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId);
updateSplitInfoSaveQuantity(parentSplitInfo, quantity_scale, iid, map, inQuantity,baseSplitInfo);
updateSplitInfoSaveQuantity(parentSplitInfo, quantity_scale, iid, map, inQuantity, baseSplitInfo);
} else {
Double price = Double.parseDouble((String) map.get("price"));
double price = Double.parseDouble((String) map.get("price"));
price = price * findSplitInfoScaleQuantity(baseSplitInfo, -1);
map.put("price", price.toString());
map.put("price", Double.toString(price));
map.put("quantity", String.valueOf(quantity_scale));
map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map);
map.remove("id");
}
} else {
// 如果不大于
paramForInsertSplitInventory.put("saveQuantity", String.valueOf(inQuantity));
paramForInsertSplitInventory.put("saveQuantity", String.valueOf(quantity));
splitUnitMapper.addSplitInventory(paramForInsertSplitInventory);
map.put("quantity", "0");
map.put("realQuantity", String.valueOf(inQuantity));
map.put("price", map.get("price").toString());
depositoryRecordService.applicationInPlace(map);
map.remove("id");
}
}

1
src/main/resources/static/js/application-out/application-out.js

@ -1005,6 +1005,7 @@ layui.use(['form', 'step', 'layer', 'jquery', 'element'], function () {
var req = {};
req.mcode = mcode;
req.quantity = val;
req.placeId = -1;
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",

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

@ -1364,6 +1364,7 @@
if (barCode.length > 0) {
barCode.empty();
}
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
@ -1391,6 +1392,11 @@
$.each(data.placePList, function (index, item) {
$('#place' + idNumber).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
});
$("#unit"+idNumber).empty();
$("#unit"+idNumber).append(new Option(data.unit,"-1"));
$.each(data.splitInfoList,function (index,item) {
$("#unit"+idNumber).append(new Option(item.newUnit,item.newUnit));
});
form.render();
materialName.value = data.mname;
materialId.value = data.id;
@ -1417,6 +1423,7 @@
req.mcode = mcode;
req.quantity = val;
req.unit = unit;
req.placeId = -1;
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",

187
src/main/resources/templates/pages/application/application-out_back.html

@ -12,17 +12,24 @@
</head>
<body>
<style>
.inputdiv{
display:flex;background-color: #fff;height: 38px;line-height: 38px;border: 1px solid rgb(238, 238, 238);
.inputdiv {
display: flex;
background-color: #fff;
height: 38px;
line-height: 38px;
border: 1px solid rgb(238, 238, 238);
}
.layui-form-label{
.layui-form-label {
padding: 9px 0px;
text-align: left;
}
.layui-input-block{
.layui-input-block {
margin-left: 80px;
}
.lay-step{
.lay-step {
display: none;
}
@ -35,24 +42,30 @@
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
<div carousel-item>
<div>
<form class="layui-form layui-form-pane" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<form class="layui-form layui-form-pane"
style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<div class="layui-card-body" id="cardItem">
<div class="layui-form-item">
<label class="layui-form-label">物料名称:</label>
<div class="layui-input-block">
<div class="inputdiv">
<input type="text" placeholder="请选择物料" class="layui-input" th:value="${materialById.getMname()}"
id="openSonByMaterial" style="border-style: none"
<input type="text" placeholder="请选择物料" class="layui-input"
th:value="${materialById.getMname()}"
id="mname" style="border-style: none"
lay-verify="required"/>
<i class="layui-icon layui-icon-search" style="display: inline" id="selectMaterial" onclick="selectMaterial(this)"></i>
<i class="layui-icon layui-icon-search" style="display: inline"
id="selectMaterial" onclick="selectMaterial(this)"></i>
</div>
<input type="text" name="mid" class="layui-input" id="mid" th:value="${materialById.getId()}"
<input type="text" name="mid" class="layui-input" id="mid"
th:value="${materialById.getId()}"
style="display: none" lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">物料编码:</label>
<div class="layui-input-block">
<input id="code" name="code" type="text" placeholder="请填写入物料编码" value="" th:value="${materialById.getCode()}"
<input id="code" name="code" type="text" placeholder="请填写入物料编码" value=""
th:value="${materialById.getCode()}"
class="layui-input" lay-verify="required">
</div>
</div>
@ -65,13 +78,28 @@
<div class="layui-form-item">
<label class="layui-form-label">物料数量:</label>
<div class="layui-input-block">
<input name="quantity" id="quantity" onblur="MaterialQuantityIsTrue(this)" type="number" placeholder="请填写入物料数量" value="" class="layui-input" lay-verify="number" required>
<input name="quantity" id="quantity"
onblur="MaterialQuantityIsTrue(this)" type="number"
placeholder="请填写入物料数量" value="" class="layui-input"
lay-verify="number" required>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id="unit" name="unit">
<option value="-1" th:text="${materialById.getUnit()}"></option>
<option th:each="splitInfo,iterStar:${materialById.getSplitInfoList()}"
th:value="${splitInfo?.getNewUnit()}"
th:text="${splitInfo?.getNewUnit()}"></option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">备注说明:</label>
<div class="layui-input-block">
<input name="applyRemark" placeholder="请填写相关原因及申请原因" value="" class="layui-input"/>
<input name="applyRemark" placeholder="请填写相关原因及申请原因" value=""
class="layui-input"/>
</div>
</div>
<div class="layui-form-item">
@ -81,6 +109,7 @@
</button>
</div>
</div>
</div>
</form>
</div>
<div>
@ -114,8 +143,13 @@
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
function MaterialQuantityIsTrue(){}
layui.use([ 'form', 'step','layer','jquery'], function () {
function MaterialQuantityIsTrue() {
}
function selectMaterial() {
}
layui.use(['form', 'step', 'layer', 'jquery'], function () {
var $ = layui.$,
form = layui.form,
step = layui.step;
@ -125,9 +159,9 @@
url: "/place/findPlaceByMid",
type: "post",
dataType: 'json',
data:JSON.stringify(temp),
data: JSON.stringify(temp),
contentType: "application/json;charset=utf-8",
success:function (res) {
success: function (res) {
$('#place').empty();
$.each(res.data, function (index, item) {
$('#place').append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
@ -146,28 +180,34 @@
url: "/material/findMatrialByCode",
type: "get",
dataType: 'json',
data:(req),
data: (req),
contentType: "application/json;charset=utf-8",
success: function (d) {
var d = d.data;
if(d == null){
if (d == null) {
layer.msg("没有该编码,请确认是否输入正确");
$("#openSonByMaterial").val("");
$("#mname").val("");
$("#mid").val("");
}else{
} else {
req.mid = d.id;
$.ajax({
url: "/place/findPlaceByMid",
type: "post",
dataType: 'json',
data:JSON.stringify(req),
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success:function (res) {
success: function (res) {
$('#place').empty();
$.each(res.data, function (index, item) {
$('#place').append(new Option(item.depositoryName+"-"+item.code, item.id));//往下拉菜单里添加元素
$('#place').append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
});
$("#unit").empty();
$("#unit").append(new Option(d.unit, "-1"));
$.each(d.splitInfoList, function (index, item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));
});
$("#openSonByMaterial").val(d.mname);
$("#mname").val(d.mname);
$("#mid").val(d.id);
form.render();
}
@ -178,7 +218,7 @@
});
});
$("#openSonByMaterial").blur(function () {
$("#mname").blur(function () {
var data = $(this).val();
var req = {};
req.mname = data;
@ -186,29 +226,34 @@
url: "/material/findInventoryByCondition",
type: "post",
dataType: 'json',
data:JSON.stringify(req),
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
if(d.count > 1){
if (d.count > 1) {
layer.msg("请点击右侧搜索确定物品");
$("#mid").val("");
$("#code").val("");
return false;
}else if(d.count === 0){
} else if (d.count === 0) {
layer.msg("没有该物品,请确认输入是否正确");
$("#mid").val("");
$("#code").val("");
return false;
}
else{
} else {
var material = d.data[0];
$("#openSonByMaterial").val(material.mname)
$("#mname").val(material.mname);
$("#mid").val(material.id);
$("#code").val(material.code);
$("#unit").empty();
$("#unit").append(new Option(material.unit, "-1"));
$.each(material.splitInfoList, function (index, item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));
});
form.render();
}
}
});
})
});
$('#openSonByDepository').on('click', function () {
layer.open({
@ -218,22 +263,23 @@
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['70%', '70%'],
move : '.layui-layer-title',
fixed:false,
move: '.layui-layer-title',
fixed: false,
content: '/selectDepository?type=2',
success: function(layero, index){
success: function (layero, index) {
var children = layero.children();
var content = $(children[1]);
var iframeChildren = $(content.children());
content.css('height','100%');
iframeChildren.css('height','100%');
content.css('height', '100%');
iframeChildren.css('height', '100%');
}
});
});
$('#selectMaterial').on('click', function () {
var mname = $("#openSonByMaterial").val();
var mname = $("#mname").val();
mname = mname.split(",")[0];
layer.open({
type: 2,
title: '弹窗内容',
@ -241,16 +287,15 @@
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['70%', '70%'],
move : '.layui-layer-title',
fixed:false,
// content: '/selectMaterial?mname='+mname+'&type=2',
content: '/getMaterialAll?mname='+mname+'&type=2',
success: function(layero, index){
move: '.layui-layer-title',
fixed: false,
content: '/selectMaterial?mname='+mname,
success: function (layero, index) {
var children = layero.children();
var content = $(children[1]);
var iframeChildren = $(content.children());
content.css('height','100%');
iframeChildren.css('height','100%');
content.css('height', '100%');
iframeChildren.css('height', '100%');
},
end: function () {
var mid = $("#mid").val();
@ -260,11 +305,17 @@
dataType: 'json',
contentType: "application/json;charset=utf-8",
success: function (d) {
var code = d.data.code;
if(code === undefined){
var code = d.data.materialById.code;
if (code === undefined) {
code = "";
}
$("#code").val(code)
$("#code").val(code);
$("#unit").empty();
$("#unit").append(new Option(d.data.materialById.unit, "-1"));
$.each(d.data.materialById.splitInfoList, function (index, item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));
});
form.render();
}
});
@ -287,28 +338,28 @@
form.on('submit(formStep)', function (data) {
data=data.field;
data = data.field;
var params = [];
data.params = params;
$.ajax({
url:"/depositoryRecord/applicationOut",
type:'post',
dataType:'json',
url: "/depositoryRecord/applicationOut",
type: 'post',
dataType: 'json',
contentType: "application/json;charset=utf-8",
data:JSON.stringify(data),
beforeSend:function () {
this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
data: JSON.stringify(data),
beforeSend: function () {
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']});
},
success:function(data){
success: function (data) {
layer.close(this.layerIndex);
if(data.status >= 300){
if (data.status >= 300) {
layer.msg(data.statusInfo.message);//失败的表情
return;
}else{
} else {
layer.msg("申请提交成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
}, function(){
}, function () {
step.next('#stepForm');
});
}
@ -316,7 +367,7 @@
complete: function () {
layer.close(this.layerIndex);
}
})
});
return false;
});
@ -335,18 +386,20 @@
//用于判断当前物料数量是否合适
MaterialQuantityIsTrue = function (obj) {
var id = obj.id.split("quantity")[1];
var mcode = $("#code" + id).val(); // 获取到当前输入的物料编码
var mcode = $("#code").val(); // 获取到当前输入的物料编码
var unit = $("#unit").val();
if (mcode === "" || mcode === undefined || mcode === null) {
layer.msg("请输入物料的正确编码!", {icon: 0, time: 500}, function () {
$("#quantity" + id).val("")
$("#quantity").val("")
});
} else {
let val = $("#quantity" + id).val();
let val = $("#quantity").val();
if (val !== null && val !== undefined && val !== '') {
var req = {};
req.mcode = mcode;
req.quantity = val;
req.unit = unit;
req.placeId = -1;
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",
@ -357,7 +410,7 @@
var flag = res.data;
if (!flag) { // 如果当前数目不合适
layer.msg("当前物料数量不足", {icon: 0, time: 500}, function () {
$("#quantity" + id).val("");
$("#quantity").val("");
});
}
@ -365,7 +418,7 @@
});
}
}
}
};
})
</script>

124
src/main/resources/templates/pages/application/application-transfer.html

@ -98,6 +98,14 @@
<input id="quantity" name="quantity" type="number" onblur="MaterialQuantityIsTrue(this)" placeholder="请填写入物料数量" value="" class="layui-input" lay-verify="number" required>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id="unit" name="unit">
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">仓库:</label>
<div class="layui-input-block">
@ -340,6 +348,14 @@
class="layui-input" lay-verify="number">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id=`+"unit"+NewIdNumber +` name=`+"unit"+NewIdNumber +`>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">仓库:</label>
<div class="layui-input-block">
@ -432,9 +448,18 @@
materialCode.value = data.mcode;
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
barCodeInput.value = result;
var idNumber = materialId.name.split("mid")[1];
var codeId = obj.id.split("barCodeImg")[1];
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(data.unit, "-1"));
var unitList = data["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
$('#place' + codeId).empty();
$.each(data.placePList, function (index, item) {
$('#place' + codeId).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
@ -510,6 +535,11 @@
if (barCode.length > 0) {
barCode.empty();
}
$("#unit"+idNumber).empty();
$("#unit"+idNumber).append(new Option(data.unit,"-1"));
$.each(data.splitInfoList,function (index,item) {
$("#unit"+idNumber).append(new Option(item.newUnit,item.newUnit));
});
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
@ -593,6 +623,14 @@
if (barCode.length > 0) {
barCode.empty();
}
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(d.unit, "-1"));
var unitList = d["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
@ -616,6 +654,7 @@
form.render();
}
$('#place' + codeId).empty();
$.each(res.data, function (index, item) {
$('#place' + codeId).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
});
@ -666,7 +705,7 @@
end: function () {
var mid = materialId.value;
$.ajax({
url: "/material/findMatrialById?mid=" + mid,
url: "/material/findMatrialById?mid=" + mid+"&type=out",
type: "get",
dataType: 'json',
contentType: "application/json;charset=utf-8",
@ -678,15 +717,23 @@
code = "";
}
codeValue.value = code;
$('#place').empty();
var idNumber = materialId.name.split("mid")[1];
$('#place'+idNumber).empty();
$.each(placeList, function (index, item) {
$('#place').append(new Option(item.depositoryName+"-"+item.code, item.id));//往下拉菜单里添加元素
$('#place'+idNumber).append(new Option(item.depositoryName+"-"+item.code, item.id));//往下拉菜单里添加元素
});
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
var idNumber = materialId.name.split("mid")[1];
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
@ -710,6 +757,12 @@
});
form.render();
}
else {
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
}
form.render();
}
});
@ -727,14 +780,17 @@
var materialChildren = parent.childNodes[5];
var codeChildren = parent.childNodes[7];
var codeItem = codeChildren.childNodes[3].childNodes;
var codeValue = codeItem[1];
var codeValue = codeItem[1].childNodes[1];
var materialItem = materialChildren.childNodes[3].childNodes[1].childNodes;
var materialName = materialItem[1];
var materialId = materialName.parentNode.parentNode.childNodes[3];
var barCodeChildren = parent.childNodes[9];
// 条形码条码
var barCodeItem = barCodeChildren.childNodes[3];
var req = {};
req.mname = data;
$.ajax({
url: "/material/findMaterialByCondition",
url: "/material/findInventoryByCondition",
type: "post",
dataType: 'json',
data:JSON.stringify(req),
@ -753,7 +809,53 @@
return false;
}
else{
var idNumber = materialId.name.split("mid")[1];
var material = d.data[0];
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
if(unitList !== null && unitList != undefined){
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
}
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
$("#" + id).remove();
$("#barCode" + idNumber).empty();
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
} else {
var barCodeSelect = `
<select id=` + "barCode" + idNumber + ` name=` + "barCode" + idNumber + `>
</select>`;
$("#" + barCodeImg.id).before(barCodeSelect);
}
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
else {
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
}
$('#place' + idNumber).empty();
$.each(material.placePList, function (index, item) {
$('#place' + idNumber).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
});
form.render();
materialName.value = material.mname;
materialId.value = material.id;
codeValue.value = material.code;
@ -784,7 +886,7 @@
iframeChildren.css('height','100%');
}
});
}
};
// 用于扫描入库位置
scanLocationByQrCode = function (obj) {
parent.wx.scanQRCode({
@ -830,13 +932,13 @@
})
}
})
}
};
//用于判断当前物料数量是否合适
MaterialQuantityIsTrue = function (obj) {
var id = obj.id.split("quantity")[1];
console.log(id)
var mcode = $("#code" + id).val(); // 获取到当前输入的物料编码
var unit = $("#unit"+id).val();
if (mcode === "" || mcode === undefined || mcode === null) {
layer.msg("请输入物料的正确编码!", {icon: 0, time: 500}, function () {
$("#quantity" + id).val("")
@ -847,6 +949,8 @@
var req = {};
req.mcode = mcode;
req.quantity = val;
req.unit = unit;
req.placeId = $("#place"+id).val();
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",
@ -865,7 +969,7 @@
});
}
}
}
};
})

2
src/main/resources/templates/pages/material/selectDepositoryByCard.html

@ -43,7 +43,7 @@
if (windowParent.childNodes.length === 25) {
depositoryChildren = windowParent.childNodes[19];
} else {
depositoryChildren = windowParent.childNodes[15];
depositoryChildren = windowParent.childNodes[17];
}
var depositoryItem = depositoryChildren.childNodes[3].childNodes[1].childNodes;
var depositoryName = depositoryItem[1];

10
src/main/resources/templates/pages/scanQrCode/ScanBarOrQrCodeOut.html

@ -54,7 +54,7 @@
var barCode = null;
layui.$(function () {
/* parent.parent.parent.wx.scanQRCode({
parent.parent.parent.wx.scanQRCode({
desc: 'scanQRCode desc',
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
scanType: ["barCode", "qrCode"], // 可以指定扫二维码还是条形码(一维码),默认二者都有
@ -73,10 +73,8 @@
}
});*/
var req = {};
req.qrCode = "1605487077042200576";
outboundLogic(req);
});
});
@ -451,7 +449,7 @@
value: quantity,
title: '请输入出库数量',
}, function (value, index, elem) {
if (value > quantity) {
if (Number(value) > Number(quantity)) {
layer.msg("非法值,重新输入!", {
icon: 0,
time: 500

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

@ -204,7 +204,7 @@
)
</insert>
<insert id="addMaterialOnPlace">
<insert id="addMaterialOnPlace" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into materialandplace(id,mid,pid,quantity)
values (
#{id},

4
target/classes/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.xml

@ -95,10 +95,10 @@
<include refid="splitInventoryAllColumns"/>
from `split_inventory` si
where 1 = 1
<if test="iid != null and iid != ''">
<if test="iid != null ">
and si.iid = #{iid}
</if>
<if test="sid != null and sid != ''">
<if test="sid != null ">
and si.sid = #{sid}
</if>
</select>

1
target/classes/static/js/application-out/application-out.js

@ -1005,6 +1005,7 @@ layui.use(['form', 'step', 'layer', 'jquery', 'element'], function () {
var req = {};
req.mcode = mcode;
req.quantity = val;
req.placeId = -1;
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",

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

@ -1364,6 +1364,7 @@
if (barCode.length > 0) {
barCode.empty();
}
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
@ -1391,6 +1392,11 @@
$.each(data.placePList, function (index, item) {
$('#place' + idNumber).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
});
$("#unit"+idNumber).empty();
$("#unit"+idNumber).append(new Option(data.unit,"-1"));
$.each(data.splitInfoList,function (index,item) {
$("#unit"+idNumber).append(new Option(item.newUnit,item.newUnit));
});
form.render();
materialName.value = data.mname;
materialId.value = data.id;
@ -1417,6 +1423,7 @@
req.mcode = mcode;
req.quantity = val;
req.unit = unit;
req.placeId = -1;
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",

187
target/classes/templates/pages/application/application-out_back.html

@ -12,17 +12,24 @@
</head>
<body>
<style>
.inputdiv{
display:flex;background-color: #fff;height: 38px;line-height: 38px;border: 1px solid rgb(238, 238, 238);
.inputdiv {
display: flex;
background-color: #fff;
height: 38px;
line-height: 38px;
border: 1px solid rgb(238, 238, 238);
}
.layui-form-label{
.layui-form-label {
padding: 9px 0px;
text-align: left;
}
.layui-input-block{
.layui-input-block {
margin-left: 80px;
}
.lay-step{
.lay-step {
display: none;
}
@ -35,24 +42,30 @@
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
<div carousel-item>
<div>
<form class="layui-form layui-form-pane" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<form class="layui-form layui-form-pane"
style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<div class="layui-card-body" id="cardItem">
<div class="layui-form-item">
<label class="layui-form-label">物料名称:</label>
<div class="layui-input-block">
<div class="inputdiv">
<input type="text" placeholder="请选择物料" class="layui-input" th:value="${materialById.getMname()}"
id="openSonByMaterial" style="border-style: none"
<input type="text" placeholder="请选择物料" class="layui-input"
th:value="${materialById.getMname()}"
id="mname" style="border-style: none"
lay-verify="required"/>
<i class="layui-icon layui-icon-search" style="display: inline" id="selectMaterial" onclick="selectMaterial(this)"></i>
<i class="layui-icon layui-icon-search" style="display: inline"
id="selectMaterial" onclick="selectMaterial(this)"></i>
</div>
<input type="text" name="mid" class="layui-input" id="mid" th:value="${materialById.getId()}"
<input type="text" name="mid" class="layui-input" id="mid"
th:value="${materialById.getId()}"
style="display: none" lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">物料编码:</label>
<div class="layui-input-block">
<input id="code" name="code" type="text" placeholder="请填写入物料编码" value="" th:value="${materialById.getCode()}"
<input id="code" name="code" type="text" placeholder="请填写入物料编码" value=""
th:value="${materialById.getCode()}"
class="layui-input" lay-verify="required">
</div>
</div>
@ -65,13 +78,28 @@
<div class="layui-form-item">
<label class="layui-form-label">物料数量:</label>
<div class="layui-input-block">
<input name="quantity" id="quantity" onblur="MaterialQuantityIsTrue(this)" type="number" placeholder="请填写入物料数量" value="" class="layui-input" lay-verify="number" required>
<input name="quantity" id="quantity"
onblur="MaterialQuantityIsTrue(this)" type="number"
placeholder="请填写入物料数量" value="" class="layui-input"
lay-verify="number" required>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id="unit" name="unit">
<option value="-1" th:text="${materialById.getUnit()}"></option>
<option th:each="splitInfo,iterStar:${materialById.getSplitInfoList()}"
th:value="${splitInfo?.getNewUnit()}"
th:text="${splitInfo?.getNewUnit()}"></option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">备注说明:</label>
<div class="layui-input-block">
<input name="applyRemark" placeholder="请填写相关原因及申请原因" value="" class="layui-input"/>
<input name="applyRemark" placeholder="请填写相关原因及申请原因" value=""
class="layui-input"/>
</div>
</div>
<div class="layui-form-item">
@ -81,6 +109,7 @@
</button>
</div>
</div>
</div>
</form>
</div>
<div>
@ -114,8 +143,13 @@
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
function MaterialQuantityIsTrue(){}
layui.use([ 'form', 'step','layer','jquery'], function () {
function MaterialQuantityIsTrue() {
}
function selectMaterial() {
}
layui.use(['form', 'step', 'layer', 'jquery'], function () {
var $ = layui.$,
form = layui.form,
step = layui.step;
@ -125,9 +159,9 @@
url: "/place/findPlaceByMid",
type: "post",
dataType: 'json',
data:JSON.stringify(temp),
data: JSON.stringify(temp),
contentType: "application/json;charset=utf-8",
success:function (res) {
success: function (res) {
$('#place').empty();
$.each(res.data, function (index, item) {
$('#place').append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
@ -146,28 +180,34 @@
url: "/material/findMatrialByCode",
type: "get",
dataType: 'json',
data:(req),
data: (req),
contentType: "application/json;charset=utf-8",
success: function (d) {
var d = d.data;
if(d == null){
if (d == null) {
layer.msg("没有该编码,请确认是否输入正确");
$("#openSonByMaterial").val("");
$("#mname").val("");
$("#mid").val("");
}else{
} else {
req.mid = d.id;
$.ajax({
url: "/place/findPlaceByMid",
type: "post",
dataType: 'json',
data:JSON.stringify(req),
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success:function (res) {
success: function (res) {
$('#place').empty();
$.each(res.data, function (index, item) {
$('#place').append(new Option(item.depositoryName+"-"+item.code, item.id));//往下拉菜单里添加元素
$('#place').append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
});
$("#unit").empty();
$("#unit").append(new Option(d.unit, "-1"));
$.each(d.splitInfoList, function (index, item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));
});
$("#openSonByMaterial").val(d.mname);
$("#mname").val(d.mname);
$("#mid").val(d.id);
form.render();
}
@ -178,7 +218,7 @@
});
});
$("#openSonByMaterial").blur(function () {
$("#mname").blur(function () {
var data = $(this).val();
var req = {};
req.mname = data;
@ -186,29 +226,34 @@
url: "/material/findInventoryByCondition",
type: "post",
dataType: 'json',
data:JSON.stringify(req),
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
if(d.count > 1){
if (d.count > 1) {
layer.msg("请点击右侧搜索确定物品");
$("#mid").val("");
$("#code").val("");
return false;
}else if(d.count === 0){
} else if (d.count === 0) {
layer.msg("没有该物品,请确认输入是否正确");
$("#mid").val("");
$("#code").val("");
return false;
}
else{
} else {
var material = d.data[0];
$("#openSonByMaterial").val(material.mname)
$("#mname").val(material.mname);
$("#mid").val(material.id);
$("#code").val(material.code);
$("#unit").empty();
$("#unit").append(new Option(material.unit, "-1"));
$.each(material.splitInfoList, function (index, item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));
});
form.render();
}
}
});
})
});
$('#openSonByDepository').on('click', function () {
layer.open({
@ -218,22 +263,23 @@
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['70%', '70%'],
move : '.layui-layer-title',
fixed:false,
move: '.layui-layer-title',
fixed: false,
content: '/selectDepository?type=2',
success: function(layero, index){
success: function (layero, index) {
var children = layero.children();
var content = $(children[1]);
var iframeChildren = $(content.children());
content.css('height','100%');
iframeChildren.css('height','100%');
content.css('height', '100%');
iframeChildren.css('height', '100%');
}
});
});
$('#selectMaterial').on('click', function () {
var mname = $("#openSonByMaterial").val();
var mname = $("#mname").val();
mname = mname.split(",")[0];
layer.open({
type: 2,
title: '弹窗内容',
@ -241,16 +287,15 @@
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['70%', '70%'],
move : '.layui-layer-title',
fixed:false,
// content: '/selectMaterial?mname='+mname+'&type=2',
content: '/getMaterialAll?mname='+mname+'&type=2',
success: function(layero, index){
move: '.layui-layer-title',
fixed: false,
content: '/selectMaterial?mname='+mname,
success: function (layero, index) {
var children = layero.children();
var content = $(children[1]);
var iframeChildren = $(content.children());
content.css('height','100%');
iframeChildren.css('height','100%');
content.css('height', '100%');
iframeChildren.css('height', '100%');
},
end: function () {
var mid = $("#mid").val();
@ -260,11 +305,17 @@
dataType: 'json',
contentType: "application/json;charset=utf-8",
success: function (d) {
var code = d.data.code;
if(code === undefined){
var code = d.data.materialById.code;
if (code === undefined) {
code = "";
}
$("#code").val(code)
$("#code").val(code);
$("#unit").empty();
$("#unit").append(new Option(d.data.materialById.unit, "-1"));
$.each(d.data.materialById.splitInfoList, function (index, item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));
});
form.render();
}
});
@ -287,28 +338,28 @@
form.on('submit(formStep)', function (data) {
data=data.field;
data = data.field;
var params = [];
data.params = params;
$.ajax({
url:"/depositoryRecord/applicationOut",
type:'post',
dataType:'json',
url: "/depositoryRecord/applicationOut",
type: 'post',
dataType: 'json',
contentType: "application/json;charset=utf-8",
data:JSON.stringify(data),
beforeSend:function () {
this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
data: JSON.stringify(data),
beforeSend: function () {
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']});
},
success:function(data){
success: function (data) {
layer.close(this.layerIndex);
if(data.status >= 300){
if (data.status >= 300) {
layer.msg(data.statusInfo.message);//失败的表情
return;
}else{
} else {
layer.msg("申请提交成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
}, function(){
}, function () {
step.next('#stepForm');
});
}
@ -316,7 +367,7 @@
complete: function () {
layer.close(this.layerIndex);
}
})
});
return false;
});
@ -335,18 +386,20 @@
//用于判断当前物料数量是否合适
MaterialQuantityIsTrue = function (obj) {
var id = obj.id.split("quantity")[1];
var mcode = $("#code" + id).val(); // 获取到当前输入的物料编码
var mcode = $("#code").val(); // 获取到当前输入的物料编码
var unit = $("#unit").val();
if (mcode === "" || mcode === undefined || mcode === null) {
layer.msg("请输入物料的正确编码!", {icon: 0, time: 500}, function () {
$("#quantity" + id).val("")
$("#quantity").val("")
});
} else {
let val = $("#quantity" + id).val();
let val = $("#quantity").val();
if (val !== null && val !== undefined && val !== '') {
var req = {};
req.mcode = mcode;
req.quantity = val;
req.unit = unit;
req.placeId = -1;
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",
@ -357,7 +410,7 @@
var flag = res.data;
if (!flag) { // 如果当前数目不合适
layer.msg("当前物料数量不足", {icon: 0, time: 500}, function () {
$("#quantity" + id).val("");
$("#quantity").val("");
});
}
@ -365,7 +418,7 @@
});
}
}
}
};
})
</script>

124
target/classes/templates/pages/application/application-transfer.html

@ -98,6 +98,14 @@
<input id="quantity" name="quantity" type="number" onblur="MaterialQuantityIsTrue(this)" placeholder="请填写入物料数量" value="" class="layui-input" lay-verify="number" required>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id="unit" name="unit">
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">仓库:</label>
<div class="layui-input-block">
@ -340,6 +348,14 @@
class="layui-input" lay-verify="number">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id=`+"unit"+NewIdNumber +` name=`+"unit"+NewIdNumber +`>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">仓库:</label>
<div class="layui-input-block">
@ -432,9 +448,18 @@
materialCode.value = data.mcode;
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
barCodeInput.value = result;
var idNumber = materialId.name.split("mid")[1];
var codeId = obj.id.split("barCodeImg")[1];
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(data.unit, "-1"));
var unitList = data["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
$('#place' + codeId).empty();
$.each(data.placePList, function (index, item) {
$('#place' + codeId).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
@ -510,6 +535,11 @@
if (barCode.length > 0) {
barCode.empty();
}
$("#unit"+idNumber).empty();
$("#unit"+idNumber).append(new Option(data.unit,"-1"));
$.each(data.splitInfoList,function (index,item) {
$("#unit"+idNumber).append(new Option(item.newUnit,item.newUnit));
});
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
@ -593,6 +623,14 @@
if (barCode.length > 0) {
barCode.empty();
}
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(d.unit, "-1"));
var unitList = d["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
@ -616,6 +654,7 @@
form.render();
}
$('#place' + codeId).empty();
$.each(res.data, function (index, item) {
$('#place' + codeId).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
});
@ -666,7 +705,7 @@
end: function () {
var mid = materialId.value;
$.ajax({
url: "/material/findMatrialById?mid=" + mid,
url: "/material/findMatrialById?mid=" + mid+"&type=out",
type: "get",
dataType: 'json',
contentType: "application/json;charset=utf-8",
@ -678,15 +717,23 @@
code = "";
}
codeValue.value = code;
$('#place').empty();
var idNumber = materialId.name.split("mid")[1];
$('#place'+idNumber).empty();
$.each(placeList, function (index, item) {
$('#place').append(new Option(item.depositoryName+"-"+item.code, item.id));//往下拉菜单里添加元素
$('#place'+idNumber).append(new Option(item.depositoryName+"-"+item.code, item.id));//往下拉菜单里添加元素
});
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
var idNumber = materialId.name.split("mid")[1];
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
@ -710,6 +757,12 @@
});
form.render();
}
else {
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
}
form.render();
}
});
@ -727,14 +780,17 @@
var materialChildren = parent.childNodes[5];
var codeChildren = parent.childNodes[7];
var codeItem = codeChildren.childNodes[3].childNodes;
var codeValue = codeItem[1];
var codeValue = codeItem[1].childNodes[1];
var materialItem = materialChildren.childNodes[3].childNodes[1].childNodes;
var materialName = materialItem[1];
var materialId = materialName.parentNode.parentNode.childNodes[3];
var barCodeChildren = parent.childNodes[9];
// 条形码条码
var barCodeItem = barCodeChildren.childNodes[3];
var req = {};
req.mname = data;
$.ajax({
url: "/material/findMaterialByCondition",
url: "/material/findInventoryByCondition",
type: "post",
dataType: 'json',
data:JSON.stringify(req),
@ -753,7 +809,53 @@
return false;
}
else{
var idNumber = materialId.name.split("mid")[1];
var material = d.data[0];
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
if(unitList !== null && unitList != undefined){
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
}
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
$("#" + id).remove();
$("#barCode" + idNumber).empty();
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
} else {
var barCodeSelect = `
<select id=` + "barCode" + idNumber + ` name=` + "barCode" + idNumber + `>
</select>`;
$("#" + barCodeImg.id).before(barCodeSelect);
}
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
else {
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
}
$('#place' + idNumber).empty();
$.each(material.placePList, function (index, item) {
$('#place' + idNumber).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素
});
form.render();
materialName.value = material.mname;
materialId.value = material.id;
codeValue.value = material.code;
@ -784,7 +886,7 @@
iframeChildren.css('height','100%');
}
});
}
};
// 用于扫描入库位置
scanLocationByQrCode = function (obj) {
parent.wx.scanQRCode({
@ -830,13 +932,13 @@
})
}
})
}
};
//用于判断当前物料数量是否合适
MaterialQuantityIsTrue = function (obj) {
var id = obj.id.split("quantity")[1];
console.log(id)
var mcode = $("#code" + id).val(); // 获取到当前输入的物料编码
var unit = $("#unit"+id).val();
if (mcode === "" || mcode === undefined || mcode === null) {
layer.msg("请输入物料的正确编码!", {icon: 0, time: 500}, function () {
$("#quantity" + id).val("")
@ -847,6 +949,8 @@
var req = {};
req.mcode = mcode;
req.quantity = val;
req.unit = unit;
req.placeId = $("#place"+id).val();
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",
@ -865,7 +969,7 @@
});
}
}
}
};
})

2
target/classes/templates/pages/material/selectDepositoryByCard.html

@ -43,7 +43,7 @@
if (windowParent.childNodes.length === 25) {
depositoryChildren = windowParent.childNodes[19];
} else {
depositoryChildren = windowParent.childNodes[15];
depositoryChildren = windowParent.childNodes[17];
}
var depositoryItem = depositoryChildren.childNodes[3].childNodes[1].childNodes;
var depositoryName = depositoryItem[1];

18
target/classes/templates/pages/scanQrCode/ScanBarOrQrCodeOut.html

@ -54,7 +54,7 @@
var barCode = null;
layui.$(function () {
/* parent.parent.parent.wx.scanQRCode({
parent.parent.parent.wx.scanQRCode({
desc: 'scanQRCode desc',
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
scanType: ["barCode", "qrCode"], // 可以指定扫二维码还是条形码(一维码),默认二者都有
@ -73,10 +73,8 @@
}
});*/
var req = {};
req.qrCode = "1605487077042200576";
outboundLogic(req);
});
});
@ -310,10 +308,10 @@
maxmin: true,
shadeClose: true,
area: ['50%', '50%'],
content: '/ScanBarOrQrCodeOut_selectMaterial?pid=' + place.id+'&mcode='+mcode+'&depositoryId='+place.did,
content: '/ScanBarOrQrCodeOut_selectMaterial?pid=' + place.id + '&mcode=' + mcode + '&depositoryId=' + place.did,
end: function () {
let flagForSelect = layui.$("#flagForSelect").val();
if(flagForSelect === 'true'){
if (flagForSelect === 'true') {
var param = {};
param.id = id;
param.placeId = place.id;
@ -397,10 +395,10 @@
maxmin: true,
shadeClose: true,
area: ['50%', '50%'],
content: '/ScanBarOrQrCodeOut_selectMaterial?pid=' + 0+'&mcode='+mcode+'&depositoryId='+depository.id,
content: '/ScanBarOrQrCodeOut_selectMaterial?pid=' + 0 + '&mcode=' + mcode + '&depositoryId=' + depository.id,
end: function () {
let flagForSelect = layui.$("#flagForSelect").val();
if(flagForSelect === 'true'){
if (flagForSelect === 'true') {
var param = {};
param.id = id;
param.qrCode = qrCode;
@ -451,7 +449,7 @@
value: quantity,
title: '请输入出库数量',
}, function (value, index, elem) {
if (value > quantity) {
if (Number(value) > Number(quantity)) {
layer.msg("非法值,重新输入!", {
icon: 0,
time: 500

Loading…
Cancel
Save