Browse Source

修改入库功能

lwx_dev
erdanergou 3 years ago
parent
commit
47dfef90cf
  1. 16
      src/main/java/com/dreamchaser/depository_manage/controller/GroupController.java
  2. 42
      src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java
  3. 3
      src/main/java/com/dreamchaser/depository_manage/entity/Inventory.java
  4. 16
      src/main/java/com/dreamchaser/depository_manage/pojo/InventoryP.java
  5. 4
      src/main/java/com/dreamchaser/depository_manage/pojo/MaterialAndPlaceForView.java
  6. 2
      src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java
  7. 2
      src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java
  8. 26
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  9. 4
      src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java
  10. 33
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  11. 38
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java
  12. 4
      src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java
  13. 35
      src/main/resources/templates/pages/split/split-out.html
  14. 2
      src/test/java/com/dreamchaser/depository_manage/TestForOther.java
  15. 35
      target/classes/templates/pages/split/split-out.html

16
src/main/java/com/dreamchaser/depository_manage/controller/GroupController.java

@ -128,10 +128,10 @@ public class GroupController {
// 获取详细信息
// 获取该物料的库存
List<Integer> inventoryByMidAndDepository = materialService.findInventoryByGroupInfoAndDepository(groupInfo, depositoryIdList);
List<Double> inventoryByMidAndDepository = materialService.findInventoryByGroupInfoAndDepository(groupInfo, depositoryIdList);
// 用于标志当前物料库存是否符合要求
boolean flagForQuantity = false;
for (Integer quantity : inventoryByMidAndDepository) {
for (Double quantity : inventoryByMidAndDepository) {
// 如果库存符合要求
if (quantity >= groupInfo.getQuantity()) {
flagForQuantity = true;
@ -402,10 +402,10 @@ public class GroupController {
// 获取详细信息
// 获取该物料的库存
List<Integer> inventoryByMidAndDepository = materialService.findInventoryByGroupInfoAndDepository(groupInfo, depositoryIdList);
List<Double> inventoryByMidAndDepository = materialService.findInventoryByGroupInfoAndDepository(groupInfo, depositoryIdList);
// 用于标志当前物料库存是否符合要求
boolean flagForQuantity = false;
for (Integer quantity : inventoryByMidAndDepository) {
for (Double quantity : inventoryByMidAndDepository) {
// 如果库存符合要求
if (quantity >= groupInfo.getQuantity()) {
flagForQuantity = true;
@ -872,7 +872,7 @@ public class GroupController {
Map<String,String> isTrueForGroup(Integer gid,Integer quantity,List<Integer> depositoryIdList){
List<GroupInfo> groupInfoByGid = groupService.findGroupInfoByGid(gid);
Boolean flag = true;
boolean flag = true;
String mname = "";
for (GroupInfo groupInfo : groupInfoByGid) {
// 获取具体信息
@ -883,8 +883,8 @@ public class GroupController {
boolean flagForInventory = false;
// 获取该物料在各仓库的库存
List<Integer> inventoryByMidAndDepository = materialService.findInventoryByGroupInfoAndDepository(groupInfo, depositoryIdList);
for (Integer integer : inventoryByMidAndDepository) {
List<Double> inventoryByMidAndDepository = materialService.findInventoryByGroupInfoAndDepository(groupInfo, depositoryIdList);
for (Double integer : inventoryByMidAndDepository) {
if (integer >= totalQuantity) {
flagForInventory = true;
break;
@ -898,7 +898,7 @@ public class GroupController {
mname = groupInfo.getMname();
}
Map<String,String> result = new HashMap<>();
result.put("flag",flag.toString());
result.put("flag", Boolean.toString(flag));
result.put("mname",mname);
return result;
}

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

@ -131,7 +131,7 @@ public class MaterialController {
total += materialService.findInventoryCount(map);
}
for (InventoryP inventoryP : list) {
inventoryP.setQuantity(1);
inventoryP.setQuantity(1.0);
}
return new RestResponse(list, total, 200);
}
@ -748,7 +748,7 @@ public class MaterialController {
if ("-1".equals(unit)) {
// 如果是基础单位
for (InventoryP inventoryP : inventoryPList) {
Integer integer = inventoryP.getBaseUnitQuantity();
double integer = inventoryP.getBaseUnitQuantity();
if (quantity <= (integer - inventoryP.getNumberOfTemporary())) { // 如果当前数量合适则跳出循环
flag = true;
break;
@ -775,7 +775,7 @@ public class MaterialController {
// 获取对应关系
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(p.getId(), inventoryP.getId());
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
double allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
saveQuantity += allInventoryForSplitInfo;
}
@ -812,7 +812,7 @@ public class MaterialController {
// 查询当前拆单记录
SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 查询以当前拆单记录为基础单位的库存
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
double allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
if (quantity <= allInventoryForSplitInfo) {
flag = true;
break;
@ -1049,14 +1049,14 @@ public class MaterialController {
// 如果当前物料不在该库位
flag = false;
}
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity() / 100);
} else {
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, materialP.getId());
if (placeAndMaterialByMidAndPid == null) {
// 如果当前物料不在该库位
flag = false;
}
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity() / 100);
}
mp = materialP;
} else {
@ -1114,7 +1114,7 @@ public class MaterialController {
// 如果当前物料不在该库位
flag = false;
} else {
materialP.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
materialP.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity()/100);
}
} else {
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, materialP.getId());
@ -1122,7 +1122,7 @@ public class MaterialController {
// 如果当前物料不在该库位
flag = false;
} else {
materialP.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
materialP.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity()/100);
}
}
mp = materialP;
@ -1399,7 +1399,7 @@ public class MaterialController {
if (placeAndMaterialByMidAndPid == null) {
isExist = false;
} else {
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity()/100);
}
} else {
// 获取物料与库位的对应关系
@ -1407,7 +1407,7 @@ public class MaterialController {
if (placeAndMaterialByMidAndPid == null) {
isExist = false;
} else {
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity() / 100);
}
}
@ -1449,14 +1449,14 @@ public class MaterialController {
// 如果当前物料不在该库位
tempflag = false;
}
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity() / 100);
} else {
// 获取物料与库位的对应关系
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, materialP.getId());
if (placeAndMaterialByMidAndPid == null) {
tempflag = false;
}
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity() / 100);
}
mp = materialP;
} else {
@ -1517,7 +1517,7 @@ public class MaterialController {
if (placeAndMaterialByMidAndPid == null) {
isExist = false;
} else {
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity() / 100);
}
} else {
// 获取物料与库位的对应关系
@ -1525,7 +1525,7 @@ public class MaterialController {
if (placeAndMaterialByMidAndPid == null) {
isExist = false;
} else {
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity()/100);
}
}
@ -1547,7 +1547,7 @@ public class MaterialController {
for (MaterialAndProducedDate materialAndProducedDate : materialAndProducedDateByMid) {
// 获取当前生产日期
producedDateList.add(DateUtil.TimeStampToDateTimeForDay(materialAndProducedDate.getProducedDate()));
material.setQuantity(materialAndProducedDate.getInventory());
material.setQuantity((double)materialAndProducedDate.getInventory() / 100);
}
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(material.getMid());
material.setSplitInfoList(splitInfoByMid);
@ -1639,7 +1639,7 @@ public class MaterialController {
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(materialP.getMid());
materialP.setSplitInfoList(splitInfoByMid);
materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition);
materialP.setBaseUnitQuantity(pm.getQuantity());
materialP.setBaseUnitQuantity((double)pm.getQuantity() / 100);
return new RestResponse(materialP, 1, 200);
} else {
return new RestResponse("", 0, 200);
@ -1666,7 +1666,7 @@ public class MaterialController {
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(materialP.getMid());
materialP.setSplitInfoList(splitInfoByMid);
materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition);
materialP.setQuantity(pm.getQuantity());
materialP.setQuantity((double)pm.getQuantity()/100);
return new RestResponse(materialP, 1, 200);
} else {
return new RestResponse("", 0, 200);
@ -1724,7 +1724,7 @@ public class MaterialController {
// 如果当前库位没有该物料
mp = null;
} else {
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity()/100);
}
} else {
@ -1734,7 +1734,7 @@ public class MaterialController {
// 如果当前库位没有该物料
mp = null;
} else {
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
mp.setQuantity((double)placeAndMaterialByMidAndPid.getQuantity()/100);
}
}
@ -1749,7 +1749,7 @@ public class MaterialController {
// 获取当前生产日期
producedDateList.add(DateUtil.TimeStampToDateTimeForDay(materialAndProducedDate.getProducedDate()));
if (flagForQuantity) {
mp.setQuantity(materialAndProducedDate.getInventory());
mp.setQuantity((double)materialAndProducedDate.getInventory()/100);
flagForQuantity = false;
}
}
@ -1926,7 +1926,7 @@ public class MaterialController {
public RestResponse findQuantityByUnit(@RequestBody Map<String, Object> map) {
if (map.containsKey("placeId")) {
// 定义最终数量
Integer quantity = 0;
double quantity = 0;
// 获取当前的计量单位
String unit = (String) map.get("unit");
// 获取当前库存id

3
src/main/java/com/dreamchaser/depository_manage/entity/Inventory.java

@ -169,7 +169,7 @@ public class Inventory {
this.materialTypeId = Long.valueOf(mpv.getType_id());
this.typeName = mpv.getTname();
this.version = mpv.getVersion();
this.quantity = mpv.getInventory();
this.quantity = mpv.getInventory().intValue();
}
public Inventory(MaterialAndPlace mp) {
@ -178,5 +178,4 @@ public class Inventory {
}
}

16
src/main/java/com/dreamchaser/depository_manage/pojo/InventoryP.java

@ -39,7 +39,7 @@ public class InventoryP {
/**
* 数量
*/
private Integer quantity;
private Double quantity;
/**
* 总金额
@ -181,7 +181,7 @@ public class InventoryP {
/**
* 用于展示的数量
*/
private Map<String,Integer> showQuantity;
private Map<String, Double> showQuantity;
/**
@ -190,7 +190,6 @@ public class InventoryP {
private Integer numberOfTemporary;
/**
* 基础单位
*/
@ -199,7 +198,7 @@ public class InventoryP {
/**
* 基础单位对应数目
*/
private Integer baseUnitQuantity;
private Double baseUnitQuantity;
/**
* 默认单位
@ -209,14 +208,13 @@ public class InventoryP {
/**
* 基础单位对应数目
*/
private Integer defaultQuantity;
private Double defaultQuantity;
public InventoryP(Integer id, Integer depositoryId, String mname, Integer quantity, Double price, String typeName) {
this.id = id;
this.mname = mname;
this.quantity = quantity;
this.quantity = (double) quantity / 100;
this.price = price;
this.typeName = typeName;
@ -226,10 +224,10 @@ public class InventoryP {
this.id = inventory.getId(); // 编号
this.mid = inventory.getMid(); // 编号
this.mname = inventory.getMname(); // 物料名称
this.quantity = inventory.getQuantity(); // 数量
this.quantity = (double) inventory.getQuantity() / 100; // 数量
this.price = inventory.getPrice(); // 单价
this.state = inventory.getState(); // 物料状态
this.amounts = inventory.getAmounts(); // 总额
this.amounts = inventory.getAmounts() / 100; // 总额
this.unit = inventory.getUnit(); // 计量单位
this.texture = inventory.getTexture(); // 材质
this.code = inventory.getCode(); // 存货编码

4
src/main/java/com/dreamchaser/depository_manage/pojo/MaterialAndPlaceForView.java

@ -23,7 +23,7 @@ public class MaterialAndPlaceForView {
/**
* 在当前库位的数量
*/
private Integer inventory;
private Double inventory;
/**
* 当前库存所处仓库
*/
@ -124,7 +124,7 @@ public class MaterialAndPlaceForView {
/**
* 对应库存
*/
private Map<String,Integer> splitInventory;
private Map<String,Double> splitInventory;
}

2
src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java

@ -147,7 +147,7 @@ public interface MaterialService {
* @param depositoryList 待查询的仓库
* @return
*/
List<Integer> findInventoryByGroupInfoAndDepository(GroupInfo groupInfo, List<Integer> depositoryList);
List<Double> findInventoryByGroupInfoAndDepository(GroupInfo groupInfo, List<Integer> depositoryList);
/**
* 根据物料id获取其在对应仓库中的库存数

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

@ -137,7 +137,7 @@ public interface SplitUnitService {
* @param allQuantityFlag 用于标志是否获取全部库存
* @return
*/
int findAllInventoryForSplitInfo(Integer splitInfoId, MaterialAndPlace materialAndPlace, Integer baseSplitInfoId, int saveQuantity, boolean allQuantityFlag);
double findAllInventoryForSplitInfo(Integer splitInfoId, MaterialAndPlace materialAndPlace, Integer baseSplitInfoId, double saveQuantity, boolean allQuantityFlag);
/**
* 根据库存id与拆单记录id获取对应拆单库存处理记录

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

@ -205,7 +205,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (materialByCondition.size() > 0) { // 如果当前存在
Inventory mt = materialByCondition.get(0);
map.put("mid", mt.getMid());
mt.setQuantity((int) (mt.getQuantity() + quantity * 100));
mt.setQuantity((int) (mt.getQuantity() + (quantity * 100)));
mt.setProducedDate(producedDate);
materialMapper.updateInventory(mt);
newMid = mt.getId();
@ -419,9 +419,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
for (ApplicationInRecord applicationInRecordP : applicationInRecordPForToday) {
// 获取当前入库类型(1物料2组合)
Integer flagForGroup = applicationInRecordP.getFlagForGroup();
sumForToday += (double)applicationInRecordP.getQuantity() / 100;
sumForToday += (double) applicationInRecordP.getQuantity() / 100;
if (applicationInRecordP.getPrice() != null) {
priceForToday += applicationInRecordP.getPrice() * (double)(applicationInRecordP.getQuantity() / 100);
priceForToday += applicationInRecordP.getPrice() * (double) (applicationInRecordP.getQuantity() / 100);
} else {
priceForToday += 0;
}
@ -430,9 +430,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
}
for (ApplicationInRecord applicationInRecordP : applicationInRecordPForYesterday) {
sumForYesterDay += (double)applicationInRecordP.getQuantity() / 100;
sumForYesterDay += (double) applicationInRecordP.getQuantity() / 100;
if (applicationInRecordP.getPrice() != null) {
priceForYesterDay += applicationInRecordP.getPrice() * (double)(applicationInRecordP.getQuantity() / 100);
priceForYesterDay += applicationInRecordP.getPrice() * (double) (applicationInRecordP.getQuantity() / 100);
} else {
priceForYesterDay += 0;
}
@ -1455,7 +1455,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前物料的库存
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, materialAndPlace, realSplitInfo.getId(), 0, true);
double allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, materialAndPlace, realSplitInfo.getId(), 0, true);
// 判断当前所有库存是否可以满足需求
if (allInventoryForSplitInfo >= nowQuantity) {
// 如果当前库存数可以满足需求
@ -2107,7 +2107,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 用于调用入库方法而创建的
Map<String, Object> paramForUpdateInventory = new HashMap<>();
paramForUpdateInventory.put("mid", record.getMid());
paramForUpdateInventory.put("quantity", record.getQuantity());
paramForUpdateInventory.put("quantity", (double) record.getQuantity() / 100);
paramForUpdateInventory.put("depositoryId", record.getDepositoryId());
paramForUpdateInventory.put("placeId", record.getPlaceId());
if (materialById.getUnit().equals(record.getAirUnit())) {
@ -2134,7 +2134,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
paramForUpdateInventory.put("producedDate", record.getMproducedDate());
Place placeById = placeMapper.findPlaceById(record.getPlaceId());
// 修改当前库存容量
updateInventoryInfoForApproval(paramForUpdateInventory, record.getQuantity(), materialById, placeById);
updateInventoryInfoForApproval(paramForUpdateInventory, (double) record.getQuantity() / 100, materialById, placeById);
} else {
// 如果是拆单单位
@ -2179,7 +2179,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
}
}
splitUnitService.realInInventoryToDepository((double) record.getQuantity(), splitInventory, paramForUpdateInventory, splitInfoForUnit, placeAndMaterialByMidAndPid, true);
splitUnitService.realInInventoryToDepository((double) record.getQuantity() / 100, splitInventory, paramForUpdateInventory, splitInfoForUnit, placeAndMaterialByMidAndPid, true);
if (paramForUpdateInventory.containsKey("applicationInId")) {
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForUpdateInventory.get("applicationInId")));
}
@ -2216,7 +2216,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
@Transactional(rollbackFor = Exception.class)
public Integer transferApply(Map<String, Object> map, UserByPort userByPort) {
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Double quantity = Double.parseDouble((String) map.get("quantity"));
double quantity = Double.parseDouble((String) map.get("quantity"));
Inventory material = materialMapper.findInventoryById(mid);
map.put("depositoryId", material.getDepositoryId());
map.put("mid", mid);
@ -3587,7 +3587,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
public List<ApplicationInRecordP> findApplicationInRecordByDepository(String depositoryId) {
List<ApplicationInRecord> recordByDepository = depositoryRecordMapper.findApplicationInRecordByDepository(depositoryId);
List<ApplicationInRecordP> list = new ArrayList<>();
for (ApplicationInRecord record:recordByDepository
for (ApplicationInRecord record : recordByDepository
) {
ApplicationInRecordP recordP = new ApplicationInRecordP(record);
list.add(recordP);
@ -3825,7 +3825,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
price = applicationInRecordP.getPrice();
}
sum += price * applicationInRecordP.getQuantity() / 10000;
count += (double)applicationInRecordP.getQuantity() / 100;
count += (double) applicationInRecordP.getQuantity() / 100;
}
BigDecimal bg = new BigDecimal(sum);
sum = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
@ -4024,7 +4024,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
double sumCount = 0;
if (type == 1) {
// 如果入库
sumCount = (double)depositoryRecordMapper.findApplicationInByMonthTest(map) / 100;
sumCount = (double) depositoryRecordMapper.findApplicationInByMonthTest(map) / 100;
} else {
// 如果出库
sumCount = depositoryRecordMapper.findApplicationOutByMonth(map);

4
src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java

@ -1024,9 +1024,9 @@ public class GroupServiceImpl implements GroupService {
// 设置id
mp.setId(materialAndPlaceForView.getId());
// 设置数量
mp.setQuantity(materialAndPlaceForView.getInventory());
mp.setQuantity(materialAndPlaceForView.getInventory().intValue());
// 获取当前库位下该拆单单位库存数
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, mp, splitInfo.getId(), 0, true);
double allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, mp, splitInfo.getId(), 0, true);
if (allInventoryForSplitInfo >= quantity) {
// 如果当前库存充足
did = materialAndPlaceForView.getDepository_id();

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

@ -522,9 +522,9 @@ public class MaterialServiceImpl implements MaterialService {
* @return
*/
@Override
public List<Integer> findInventoryByGroupInfoAndDepository(GroupInfo groupInfo, List<Integer> depositoryList) {
public List<Double> findInventoryByGroupInfoAndDepository(GroupInfo groupInfo, List<Integer> depositoryList) {
// 用于存储各仓库的库存
List<Integer> result = new ArrayList<>();
List<Double> result = new ArrayList<>();
// 获取当前物料在组合中的单位
String unit = groupInfo.getUnit();
@ -537,9 +537,9 @@ public class MaterialServiceImpl implements MaterialService {
map.put("did", depositoryId);
Inventory inventory = materialMapper.findInventoryByMidAndDid(map);
if (inventory != null) {
result.add(inventory.getQuantity());
result.add((double)inventory.getQuantity() / 100);
} else {
result.add(0);
result.add(0.0);
}
}
} else {
@ -555,13 +555,13 @@ public class MaterialServiceImpl implements MaterialService {
paramForSplitInventory.put("sid", splitInfo.getId());
for (Integer depositoryId : depositoryList) {
Integer quantity = 0;
double quantity = 0;
// 获取该物料在该仓库下的映射关系
List<MaterialAndPlaceForView> placeAndMaterialByDidAndMid = placeService.findPlaceAndMaterialByDidAndMid(depositoryId, groupInfo.getMid());
for (MaterialAndPlaceForView materialAndPlaceForView : placeAndMaterialByDidAndMid) {
paramForSplitInventory.put("iid", materialAndPlaceForView.getId());
MaterialAndPlace materialAndPlace = new MaterialAndPlace();
materialAndPlace.setQuantity(materialAndPlaceForView.getInventory());
materialAndPlace.setQuantity((int)(materialAndPlaceForView.getInventory() / 100));
materialAndPlace.setId(materialAndPlaceForView.getId());
quantity += splitUnitService.findAllInventoryForSplitInfo(-1, materialAndPlace, splitInfo.getId(), 0, true);
}
@ -813,9 +813,9 @@ public class MaterialServiceImpl implements MaterialService {
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(m.getId(), m.getDepositoryId());
Map<String, Integer> splitInventoryForUnit = new HashMap<>();
splitInventoryForUnit.put(inventory.getUnit(), inventory.getQuantity());
m.setBaseUnitQuantity(inventory.getQuantity());
Map<String, Double> splitInventoryForUnit = new HashMap<>();
splitInventoryForUnit.put(inventory.getUnit(), (double)inventory.getQuantity() / 100);
m.setBaseUnitQuantity((double)inventory.getQuantity() / 100);
// 定义最后展示单位及数目
String unit = inventory.getUnit();
@ -833,7 +833,7 @@ public class MaterialServiceImpl implements MaterialService {
for (SplitInfo splitInfo : splitInfoByMid
) {
// 获取当前拆单单位的总数
int saveQuantity = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
double saveQuantity = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
if (splitInventoryForUnit.containsKey(splitInfo.getNewUnit())) {
// 如果当前存在该拆单类型的记录
@ -848,7 +848,8 @@ public class MaterialServiceImpl implements MaterialService {
if (inventory.getPrice() == null) {
inventory.setPrice(0.0);
}
BigDecimal bigDecimal = BigDecimal.valueOf(inventory.getPrice() / splitInfo.getQuantity());
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
BigDecimal bigDecimal = BigDecimal.valueOf(inventory.getPrice() / scale);
double split_price = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
amounts += split_price * saveQuantity;
unit = splitInfo.getNewUnit();
@ -2650,13 +2651,13 @@ public class MaterialServiceImpl implements MaterialService {
// 获取其对应的拆单记录
List<SplitInfo> list = splitUnitMapper.findSplitInfoByMid(mpv.getMid());
// 用于获取对应的拆单记录库存
Map<String, Integer> splitInventory = new HashMap<>();
Map<String, Double> splitInventory = new HashMap<>();
// 获取对应物料
MaterialAndPlace placeAndMaterial = placeService.findPlaceAndMaterialById(mpv.getId());
for (SplitInfo si : list
) {
// 获取当前拆单单位对应的库存数
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterial, si.getId(), 0, true);
double allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterial, si.getId(), 0, true);
splitInventory.put(si.getNewUnit(), allInventoryForSplitInfo);
}
// 创建默认单位的拆单信息
@ -2685,13 +2686,13 @@ public class MaterialServiceImpl implements MaterialService {
mpv.setTakingInventory(number);
if ("Inventory_down".equals(takingResult)) {
// 如果盘亏
mpv.setStockTakingQuantity(splitInventory.get(unit) - ObjectFormatUtil.toInteger(number));
mpv.setStockTakingQuantity((int)(splitInventory.get(unit) - ObjectFormatUtil.toDouble(number)));
} else if ("Inventory_up".equals(takingResult)) {
// 如果盘盈
mpv.setStockTakingQuantity(splitInventory.get(unit) + ObjectFormatUtil.toInteger(number));
mpv.setStockTakingQuantity((int)(splitInventory.get(unit) + ObjectFormatUtil.toDouble(number)));
} else {
// 如果正常
mpv.setStockTakingQuantity(splitInventory.get(unit));
mpv.setStockTakingQuantity((int)(splitInventory.get(unit) * 100));
}
}

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

@ -89,7 +89,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前仓库是否有用户进行管理入库审批
// 获取当前类型是否有用户进行管理入库审批
Map<String, Object> paramForMtRole = new HashMap<>();
Material materialById = materialMapper.findMaterialById(ObjectFormatUtil.toInteger(map.get("mid")));
paramForMtRole.put("mtid", materialById.getMaterialTypeId());
@ -225,9 +225,11 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 计算要进的数目
int quantity_in = (realQuantity / (scale * 100));
// 更新处理数量
disposeQuantity = disposeQuantity * 100 + quantity_in;
disposeQuantity = disposeQuantity * 100 + quantity_in * 100;
// 拆单库存实际入库的数量
realQuantity = realQuantity - quantity_in * scale;
realQuantity = realQuantity - quantity_in * 100 * scale;
}else{
disposeQuantity *= 100;
}
// 设置当前计量单位的库存
splitInventory.setSaveQuantity(realQuantity);
@ -301,9 +303,9 @@ public class SplitUnitServiceImpl implements SplitUnitService {
} else {
// 如果不大于设置的进制数量
paramForInsertSplitInventory.put("inQuantity", quantity);
paramForInsertSplitInventory.put("inQuantity", quantity * 100);
paramForInsertSplitInventory.put("outQuantity", 0);
paramForInsertSplitInventory.put("saveQuantity", saveQuantity);
paramForInsertSplitInventory.put("saveQuantity", saveQuantity * 100);
if (placeAndMaterialByMidAndPid != null) {
// 如果有库存记录
@ -390,7 +392,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
* @param allQuantityFlag 用于标志是否获取全部库存
* @return
*/
public int findAllInventoryForSplitInfo(Integer splitInfoId, MaterialAndPlace materialAndPlace, Integer baseSplitInfoId, int saveQuantity, boolean allQuantityFlag) {
public double findAllInventoryForSplitInfo(Integer splitInfoId, MaterialAndPlace materialAndPlace, Integer baseSplitInfoId, double saveQuantity, boolean allQuantityFlag) {
if (allQuantityFlag) {
// 用于标志是否第一次计算
@ -406,16 +408,15 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 如果当前获取的为对应基础单位的所有库存
// 如果是第一次计算
if (Integer.compare(saveQuantity, 0) == 0) {
if (saveQuantity == 0.0) {
// 如果是第一次计算
paramForSplitInventory.put("sid", baseSplitInfoId);
// 当前基础单位的库存
SplitInventory baseSplitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
if (baseSplitInventory != null) {
saveQuantity += baseSplitInventory.getSaveQuantity();
saveQuantity += (double) baseSplitInventory.getSaveQuantity() / 100;
}
}
if (Integer.compare(-1, splitInfoId) != 0) {
@ -425,7 +426,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
paramForSplitInventory.put("sid", splitInfoId);
SplitInventory splitInventoryByIidAndSid = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
if (splitInventoryByIidAndSid != null) {
saveQuantity += splitInventoryByIidAndSid.getSaveQuantity() * splitInfoByParentId.getQuantity();
saveQuantity += (double) (splitInventoryByIidAndSid.getSaveQuantity() / 100) * splitInfoByParentId.getQuantity();
}
}
@ -446,12 +447,12 @@ public class SplitUnitServiceImpl implements SplitUnitService {
return findAllInventoryForSplitInfo(parentSplitInfo.getId(), materialAndPlace, baseSplitInfoId, saveQuantity, allQuantityFlag);
} else {
int splitInfoScaleQuantity = findSplitInfoScaleQuantity(baseSplitInfo, -1);
return saveQuantity + materialAndPlace.getQuantity() * splitInfoScaleQuantity;
return saveQuantity + (double) (materialAndPlace.getQuantity() / 100) * splitInfoScaleQuantity;
}
} else {
int splitInfoScaleQuantity = findSplitInfoScaleQuantity(baseSplitInfo, -1);
return saveQuantity + materialAndPlace.getQuantity() * splitInfoScaleQuantity;
return saveQuantity + (double) (materialAndPlace.getQuantity() / 100) * splitInfoScaleQuantity;
}
}
@ -466,14 +467,14 @@ public class SplitUnitServiceImpl implements SplitUnitService {
paramForSplitInventory.put("iid", materialAndPlace.getId());
// 如果当前获取的为对应基础单位的所有库存
if (Integer.compare(saveQuantity, 0) == 0) {
if (saveQuantity == 0.0) {
// 如果是第一次计算
paramForSplitInventory.put("sid", baseSplitInfoId);
// 当前基础单位的库存
SplitInventory baseSplitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
saveQuantity += baseSplitInventory.getSaveQuantity();
saveQuantity += (double)baseSplitInventory.getSaveQuantity() / 100;
}
// 获取当前拆单记录与基础拆单记录之间的进制
@ -481,7 +482,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
paramForSplitInventory.put("sid", splitInfoId);
// 获取当前拆单记录的库存
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
saveQuantity += splitInventory.getSaveQuantity() * splitInfoScaleQuantity;
saveQuantity += (double)splitInventory.getSaveQuantity() / 100 * splitInfoScaleQuantity;
// 获取当前的子类
SplitInfo splitInfoByParentId = splitUnitMapper.findSplitInfoByParentId(splitInfoId);
@ -577,12 +578,12 @@ public class SplitUnitServiceImpl implements SplitUnitService {
if (splitInventory != null) {
// 如果拆单库存处理记录不为空
if ((double)(splitInventory.getSaveQuantity() / 100) + saveQuantity >= splitInfo.getQuantity()) {
if ((double) (splitInventory.getSaveQuantity() / 100) + saveQuantity >= splitInfo.getQuantity()) {
// 当前库存拆单记录与新入库的数目大于预设的进制
// 定义当前实际修改数量
double new_saveQuantity = (double)splitInventory.getSaveQuantity() / 100 + saveQuantity - splitInfo.getQuantity();
double new_saveQuantity = (double) splitInventory.getSaveQuantity() / 100 + saveQuantity - splitInfo.getQuantity();
// 令计算处理数量+1
disposeQuantity += 1;
@ -624,8 +625,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
}
}
else {
} else {
// 如果为空
Map<String, Object> paramForInsertSplitInventory = new HashMap<>();

4
src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java

@ -927,7 +927,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 拆单库存如果不能满足
// 获取当前拆单单位对应的所有库存
int allSplitInventory = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
double allSplitInventory = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
if (allSplitInventory - inventory >= 0) {
// 获取剩余不足的数量
@ -1043,7 +1043,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果不存在拆单记录
// 获取当前拆单单位对应的库存数
int splitInfoInventory = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
double splitInfoInventory = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
if (Integer.compare(minRecord.getNewInventory(), 0) == 0) {
// 如果盘点数量为0

35
src/main/resources/templates/pages/split/split-out.html

@ -76,6 +76,11 @@
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
<script id="splitCode" type="text/html">
<a id="{{d.id}}" onclick="showDetail(this)">{{d.mcode}}</a>
</script>
<script type="text/html" id="currentTableBar">
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail" th:style="'display:'+${display}">详情</a>
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete" th:style="'display:'+${display}">删除</a>
@ -123,7 +128,7 @@
cols: [
[
{type: "checkbox", width: 50},
{field: 'mcode', width: 150, title: '存货编码', sort: true},
{title: '存货编码', width: 150, templet: '#splitCode'},
{field: 'mname', width: 120, title: '物料名称', sort: false},
{field: 'typeName', width: 150, title: '物料种类'},
{field: 'version', width: 200, title: '规格型号', sort: false},
@ -303,7 +308,7 @@
}
}, 'data');
}
})
});
$(window).on("resize", function () {
layer.full(index);
});
@ -497,6 +502,32 @@
});
showDetail = function (obj) {
var index = layer.open({
title: '拆单详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/split_edit?id=' + obj.id,
end: function () {
//执行搜索重载
table.reload('currentTableId', {
url: '/split/split_out',
page: {
curr: 1
}
}, 'data');
}
});
$(window).on("resize", function () {
layer.full(index);
});
}
});
</script>

2
src/test/java/com/dreamchaser/depository_manage/TestForOther.java

@ -46,7 +46,7 @@ public class TestForOther {
ApprovalInfo_Details_Approver approver = new ApprovalInfo_Details_Approver();
approver.setUserId("PangFuZhen");
approvalInfo.setApprover(approver);
depositoryRecordService.reviewByQyWxApprovalIn("[1]",approvalInfo,"460f46eaefb46bb0c171029f62e2cea6","2","202303170008");
depositoryRecordService.reviewByQyWxApprovalIn("[6]",approvalInfo,"460f46eaefb46bb0c171029f62e2cea6","2","202303170017");
}

35
target/classes/templates/pages/split/split-out.html

@ -76,6 +76,11 @@
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
<script id="splitCode" type="text/html">
<a id="{{d.id}}" onclick="showDetail(this)">{{d.mcode}}</a>
</script>
<script type="text/html" id="currentTableBar">
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail" th:style="'display:'+${display}">详情</a>
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete" th:style="'display:'+${display}">删除</a>
@ -123,7 +128,7 @@
cols: [
[
{type: "checkbox", width: 50},
{field: 'mcode', width: 150, title: '存货编码', sort: true},
{title: '存货编码', width: 150, templet: '#splitCode'},
{field: 'mname', width: 120, title: '物料名称', sort: false},
{field: 'typeName', width: 150, title: '物料种类'},
{field: 'version', width: 200, title: '规格型号', sort: false},
@ -303,7 +308,7 @@
}
}, 'data');
}
})
});
$(window).on("resize", function () {
layer.full(index);
});
@ -497,6 +502,32 @@
});
showDetail = function (obj) {
var index = layer.open({
title: '拆单详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/split_edit?id=' + obj.id,
end: function () {
//执行搜索重载
table.reload('currentTableId', {
url: '/split/split_out',
page: {
curr: 1
}
}, 'data');
}
});
$(window).on("resize", function () {
layer.full(index);
});
}
});
</script>

Loading…
Cancel
Save