设计管理:材料明细表料单阶段比较报告

This commit is contained in:
suncz
2024-05-09 14:53:21 +08:00
parent eec463ac58
commit 2b06717f72
6 changed files with 184 additions and 39 deletions

View File

@@ -107,7 +107,7 @@ public class MaterialOrderController extends BaseController {
modelMap.addAttribute("productList", productService.findAll());
modelMap.addAttribute("type", orderQuery.getMaterialType());
modelMap.addAttribute("pageType",pageType);
// modelMap.addAttribute("adminId",admin.getId());
modelMap.addAttribute("adminId",admin.getId());
Page<MaterialOrder> page = (Page<MaterialOrder>) modelMap.get("page");
Map<Long,String> map = new HashMap<>();
for (MaterialOrder materialOrder : page.getContent()){
@@ -433,14 +433,30 @@ public class MaterialOrderController extends BaseController {
}
/**
* 导入明细表页面中 根据前缀和阶段找以往阶段的料单
* 导入明细表页面中及阶段比较功能 根据前缀和阶段找以往阶段的料单
*/
@RequestMapping(value = "/findPrevStageListDialog")
public String findPrevStageListDialog(ModelMap modelMap, Long adminId, String preTitle, Long stage) {
public String findPrevStageListDialog(ModelMap modelMap, Long adminId, String preTitle, Long stage, Long materialOrderId) {
modelMap.addAttribute("materialOrderId", materialOrderId);
modelMap.addAttribute("materialOrderList", materialOrderService.findPrevStageList(adminId, preTitle, stage));
return "materialOrder/dialog/findPrevStageListDialog";
}
/**
* 对以往阶段的料单进行阶段比较
*/
@RequestMapping(value = "/PrevStageComparisonExcel")
@ResponseBody
public RespData PrevStageComparisonExcel(Long materialOrderId) {
MaterialOrder materialOrder = materialOrderService.find(materialOrderId);
if(materialOrder.getStageNum()==1){
return RespData.error("该料单是第一阶段,无法进行阶段比较");
} else {
materialOrderService.PrevStageComparisonExcel(materialOrderId);
return RespData.success("料单比较成功");
}
}
/**
* 导入明细表

View File

@@ -83,6 +83,8 @@ public class MaterialOrder extends OrderBase{
// this.stage = stage;
// }
private Integer stage;
private String stageName;
private String stageCode;
@@ -196,6 +198,14 @@ public class MaterialOrder extends OrderBase{
this.bidStatus = bidStatus;
}
public Integer getStage() {
return stage;
}
public void setStage(Integer stage) {
this.stage = stage;
}
public String getStageName() {
return stageName;
}

View File

@@ -682,6 +682,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
}
}
}
materialOrder.setStage(stage.getId().intValue());
materialOrder.setStageCode(stage.getCode());
materialOrder.setStageName(stage.getName());
materialOrder.setStageNum(stage.getStageNum());
@@ -1037,23 +1038,24 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
BigDecimal useCount = countMap.get(str);
if (useCount!=null){
count = needCount.subtract(useCount);
countMap.remove(str);
} else {
count = needCount;
}
//count = needCount.subtract(useCount);
// count = needCount.subtract(useCount);
//后续阶段数量意外减少
if (count.compareTo(BigDecimal.ZERO)<0){
Map<String,Object> map = new HashMap<>();
map.put("ind",item.getInd());
map.put("name",item.getName());
map.put("unit",item.getUnitAccount());
map.put("site",item.getSiteAccount());
map.put("line",item.getLineAccount());
map.put("code",item.getProductCode());
map.put("longDescription",item.getLongDescription());
map.put("needCount",needCount);
map.put("preCount",useCount);
map.put("errorMessage","阶段提升后采购数量减少");
specialList.add(map);
// Map<String,Object> map = new HashMap<>();
// map.put("ind",item.getInd());
// map.put("name",item.getName());
// map.put("unit",item.getUnitAccount());
// map.put("site",item.getSiteAccount());
// map.put("line",item.getLineAccount());
// map.put("code",item.getProductCode());
// map.put("longDescription",item.getLongDescription());
// map.put("needCount",needCount);
// map.put("preCount",useCount);
// map.put("errorMessage","当前阶段较以往阶段采购数量减少");
// specialList.add(map);
count = BigDecimal.ZERO;
}
}
@@ -1135,22 +1137,8 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
throw new ImportExcelException(failNum+"条导入失败", "3", map);
}
}
if (!firstStage && countMap!=null && !countMap.isEmpty()){
for (Map.Entry<String, BigDecimal> entry : countMap.entrySet()) {
Map<String,Object> map = new HashMap<>();
map.put("ind","");
map.put("name",entry.getKey().split("_")[0]);
map.put("unit",entry.getKey().split("_")[15]);
map.put("site",entry.getKey().split("_")[14]);
map.put("line",entry.getKey().split("_")[12]);
map.put("code",entry.getKey().split("_")[16]);
map.put("longDescription",entry.getKey().split("_")[5]);
map.put("needCount","");
map.put("preCount",entry.getValue());
map.put("errorMessage","上阶段有,现阶段没有");
specialList.add(map);
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
if (!firstStage){
PrevStageComparisonExcel(materialOrder.getId());
}
return specialList.size();
}
@@ -1182,18 +1170,107 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
lm.put("unit",item.get("unit"));
lm.put("site",item.get("site"));
lm.put("line",item.get("line"));
lm.put("code", item.get("code"));
lm.put("code",item.get("code"));
lm.put("longDescription", item.get("longDescription"));
lm.put("needCount", item.get("needCount"));
lm.put("preCount", item.get("preCount"));
lm.put("errorMessage", item.get("errorMessage"));
listMap.add(lm);
}
value.put("maplist", listMap);
ExcelUtils.export(response, value, params, "料单数量问题.xlsx");
ExcelUtils.export(response, value, params, "料单阶段比较报告.xlsx");
}
@Transactional
public void PrevStageComparisonExcel(Long materialOrderId){
specialList = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
MaterialOrder materialOrder = find(materialOrderId);
//获取以前阶段
Map<String,BigDecimal> prevMap = new HashMap<>();
Map<String,String> LongMap = new HashMap<>();
List<MaterialOrder> prevMaterialOrderList = findByStageNum(materialOrder.getPreTitle(), materialOrder.getStageNum(), materialOrder.getProgressId());
for (MaterialOrder prevMaterialOrder : prevMaterialOrderList) {
List<MaterialOrderItem> prevItemList = materialOrderItemService.findByVersionNum(prevMaterialOrder.getVersionNum(), prevMaterialOrder.getId());
for (MaterialOrderItem prevItem : prevItemList){
String str = prevItem.getName()+"_"+prevItem.getUnitAccount()+"_"+prevItem.getSiteAccount()
+"_"+prevItem.getLineAccount()+"_"+prevItem.getProductCode();
if (!prevMap.containsKey(str)){
prevMap.put(str,prevItem.getCount());
}else {
BigDecimal prevCount = prevMap.get(str).add(prevItem.getCount());
prevMap.put(str,prevCount);
}
LongMap.put(str,prevItem.getLongDescription());
}
}
//获取当前阶段
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), materialOrder.getId());
for (MaterialOrderItem item : itemList){
String str = item.getName()+"_"+item.getUnitAccount()+"_"+item.getSiteAccount()
+"_"+item.getLineAccount()+"_"+item.getProductCode();
if (prevMap.containsKey(str)){
BigDecimal prevCount = prevMap.get(str);
if (prevCount.compareTo(item.getNeedCount()) > 0){
map = new HashMap<>();
map.put("ind",item.getInd());
map.put("name",item.getName());
map.put("unit",item.getUnitAccount());
map.put("site",item.getSiteAccount());
map.put("line",item.getLineAccount());
map.put("code",item.getProductCode());
map.put("longDescription",item.getLongDescription());
map.put("needCount",item.getNeedCount());
map.put("preCount",prevCount);
map.put("errorMessage","当前阶段较以往阶段采购数量减少");
specialList.add(map);
} else if (prevCount.compareTo(item.getNeedCount()) < 0) {
map = new HashMap<>();
map.put("ind",item.getInd());
map.put("name",item.getName());
map.put("unit",item.getUnitAccount());
map.put("site",item.getSiteAccount());
map.put("line",item.getLineAccount());
map.put("code",item.getProductCode());
map.put("longDescription",item.getLongDescription());
map.put("needCount",item.getNeedCount());
map.put("preCount",prevCount);
map.put("errorMessage","当前阶段较以往阶段采购数量增加");
specialList.add(map);
}
prevMap.remove(str);
} else {
map = new HashMap<>();
map.put("ind",item.getInd());
map.put("name",item.getName());
map.put("unit",item.getUnitAccount());
map.put("site",item.getSiteAccount());
map.put("line",item.getLineAccount());
map.put("code",item.getProductCode());
map.put("longDescription",item.getLongDescription());
map.put("needCount",item.getNeedCount());
map.put("preCount",' ');
map.put("errorMessage","当前阶段料单新增采购");
specialList.add(map);
}
}
for (Map.Entry<String,BigDecimal> entry : prevMap.entrySet()) {
map = new HashMap<>();
map.put("ind",' ');
map.put("name",entry.getKey().split("_")[0]);
map.put("unit",entry.getKey().split("_")[1]);
map.put("site",entry.getKey().split("_")[2]);
map.put("line",entry.getKey().split("_")[3]);
map.put("code",entry.getKey().split("_")[4]);
map.put("longDescription",LongMap.get(entry.getKey()));
map.put("needCount",' ');
map.put("preCount",entry.getValue());
map.put("errorMessage","以往阶段已采购,当前阶段没有采购");
specialList.add(map);
}
}
// @Transactional(propagation = Propagation.NESTED)
//老版
@Transactional