refactor: 料单导入,新增选项“是否考虑管线号”,不是的话,产生的修改是原先不同管线号记录会合并,管线号设置为空,合并值和前阶段合并值加减;料单阶段比较报告修改:后阶段如果是不考虑管线号的,前阶段数据也处理成不考虑管线号
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.vverp.constant;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
|
||||
public class MaterialOrderItemConsts {
|
||||
|
||||
// 根据当前阶段的是否考虑管线号,返回之前阶段的管线号
|
||||
public static String getPrevStageLineAccount(Boolean ignoreLineAccount, String prevStageLineAccount) {
|
||||
return BooleanUtils.isTrue(ignoreLineAccount) ? "-" : prevStageLineAccount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -466,7 +466,7 @@ public class MaterialOrderController extends BaseController {
|
||||
*/
|
||||
@RequestMapping(value = "/uploadOrderExcel")
|
||||
@ResponseBody
|
||||
public RespData uploadOrderExcel(MultipartFile file, Long adminId, String preTitle, Integer flowNum, String code, Long orderId, Long stage,String memo,String upReason,String name) {
|
||||
public RespData uploadOrderExcel(MultipartFile file, Long adminId, String preTitle, Integer flowNum, String code, Long orderId, Long stage,String memo,String upReason,String name, Boolean ignoreLineAccount) {
|
||||
if (orderId == null) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
@@ -480,6 +480,9 @@ public class MaterialOrderController extends BaseController {
|
||||
if (stage == null) {
|
||||
return RespData.error("阶段不能为空");
|
||||
}
|
||||
if (ignoreLineAccount == null) {
|
||||
return RespData.error("是否考虑管线号不能为空");
|
||||
}
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
@@ -490,7 +493,7 @@ public class MaterialOrderController extends BaseController {
|
||||
try {
|
||||
System.out.println("开始导入文件");
|
||||
if (orderId == null) {
|
||||
Integer specialNum = materialOrderService.saveFile(file, adminId, preTitle, flowNum, code, stage,memo,name);
|
||||
Integer specialNum = materialOrderService.saveFile(file, adminId, preTitle, flowNum, code, stage,memo,name, ignoreLineAccount);
|
||||
if (specialNum >0){
|
||||
return RespData.warn("导入成功");
|
||||
}
|
||||
|
||||
@@ -131,6 +131,9 @@ public class MaterialOrder extends OrderBase{
|
||||
/** 是否创建订货单 */
|
||||
private Boolean hasPurchaseOrder;
|
||||
|
||||
/** 匹配忽略管线号 */
|
||||
private Boolean ignoreLineAccount;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -295,4 +298,12 @@ public class MaterialOrder extends OrderBase{
|
||||
public void setHasPurchaseOrder(Boolean hasPurchaseOrder) {
|
||||
this.hasPurchaseOrder = hasPurchaseOrder;
|
||||
}
|
||||
|
||||
public Boolean getIgnoreLineAccount() {
|
||||
return ignoreLineAccount;
|
||||
}
|
||||
|
||||
public void setIgnoreLineAccount(Boolean ignoreLineAccount) {
|
||||
this.ignoreLineAccount = ignoreLineAccount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.hutool.core.comparator.CompareUtil;
|
||||
import com.vverp.base.exception.ImportExcelException;
|
||||
import com.vverp.constant.MaterialOrderItemConsts;
|
||||
import com.vverp.dao.MaterialOrderDao;
|
||||
import com.vverp.dto.CellDto;
|
||||
import com.vverp.dto.CompanyQuery;
|
||||
@@ -18,6 +19,7 @@ import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.util.*;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
@@ -603,7 +605,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
|
||||
// @Transactional(propagation = Propagation.NESTED)
|
||||
@Transactional
|
||||
public Integer saveFile(MultipartFile file, Long adminId, String preTitle, Integer flowNum, String code, Long stageId,String remark,String orderName) {
|
||||
public Integer saveFile(MultipartFile file, Long adminId, String preTitle, Integer flowNum, String code, Long stageId,String remark,String orderName, Boolean ignoreLineAccount) {
|
||||
specialList = new ArrayList<>();
|
||||
List<ProductType> productTypeList = new ArrayList<>();
|
||||
Admin admin = adminService.find(adminId);
|
||||
@@ -620,6 +622,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
materialOrder.setPreTitle(preTitle);
|
||||
materialOrder.setProgressId(admin.getNowProgress());
|
||||
materialOrder.setName(orderName);
|
||||
materialOrder.setIgnoreLineAccount(ignoreLineAccount);
|
||||
if (admin.getNowProgress() != null) {
|
||||
Progress progress = progressService.find(admin.getNowProgress());
|
||||
materialOrder.setProgressName(progress.getName());
|
||||
@@ -651,6 +654,8 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
|
||||
|
||||
Map<String,BigDecimal> countMap = new HashMap<>();
|
||||
Map<String, MaterialOrderItem> ignoreLineAccountMergeItemMap = new HashMap<>();
|
||||
Set<String> ignoreLineAccountSubtractUseCountSet = new HashSet<>();
|
||||
if (!firstStage){
|
||||
List<MaterialOrder> materialOrderList = findByStageNum(preTitle, stage.getStageNum(),admin.getNowProgress());
|
||||
// if(materialOrderList.size()<1){
|
||||
@@ -668,7 +673,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
+"_"+wallThicknessLStr+"_"+materialOrderItem.getMaterial()
|
||||
+"_"+materialOrderItem.getMemo()+"_"+materialOrderItem.getSize()
|
||||
+"_"+materialOrderItem.getSpecialRequest()+"_"+materialOrderItem.getInsulationCode()
|
||||
+"_"+materialOrderItem.getLineAccount()+"_"+materialOrderItem.getAreaAccount()
|
||||
+"_"+ MaterialOrderItemConsts.getPrevStageLineAccount(ignoreLineAccount, materialOrderItem.getLineAccount()) +"_"+materialOrderItem.getAreaAccount()
|
||||
+"_"+materialOrderItem.getSiteAccount()+"_"+materialOrderItem.getUnitAccount()
|
||||
+"_"+materialOrderItem.getProductCode()+"_"+materialOrderItem.getPurchaseCode()
|
||||
+"_"+materialOrderItem.getMakeCode()+"_"+materialOrderItem.getMaterialType()
|
||||
@@ -823,7 +828,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
String areaAccount = ExcelUtil2.getCellValue(row.getCell(2));
|
||||
String unitAccount = ExcelUtil2.getCellValue(row.getCell(3));
|
||||
String siteAccount = ExcelUtil2.getCellValue(row.getCell(4));
|
||||
String lineAccount = ExcelUtil2.getCellValue(row.getCell(5));
|
||||
String lineAccount = BooleanUtils.isTrue(ignoreLineAccount) ? "-" : ExcelUtil2.getCellValue(row.getCell(5));
|
||||
String codeType = ExcelUtil2.getCellValue(row.getCell(6));
|
||||
String purchaseCode = ExcelUtil2.getCellValue(row.getCell(7));
|
||||
String shortDescription = ExcelUtil2.getCellValue(row.getCell(8));
|
||||
@@ -1011,6 +1016,20 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
}
|
||||
BigDecimal count = BigDecimal.ZERO;
|
||||
BigDecimal negativeCount = BigDecimal.ZERO;
|
||||
String diameterSStr = item.getDiameterS()==null?"null":item.getDiameterS().stripTrailingZeros().toString();
|
||||
String diameterLStr = item.getDiameterL()==null?"null":item.getDiameterL().stripTrailingZeros().toString();
|
||||
String wallThicknessSStr = item.getWallThicknessS()==null?"null":item.getWallThicknessS();
|
||||
String wallThicknessLStr = item.getWallThicknessL()==null?"null":item.getWallThicknessL();
|
||||
String str = item.getName()+"_"+item.getProductId()+"_"+diameterSStr
|
||||
+"_"+diameterLStr+"_"+wallThicknessSStr+"_"+item.getShortDescription()
|
||||
+"_"+wallThicknessLStr+"_"+item.getMaterial()
|
||||
+"_"+item.getMemo()+"_"+item.getSize()
|
||||
+"_"+item.getSpecialRequest()+"_"+item.getInsulationCode()
|
||||
+"_"+item.getLineAccount()+"_"+item.getAreaAccount()
|
||||
+"_"+item.getSiteAccount()+"_"+item.getUnitAccount()
|
||||
+"_"+item.getProductCode()+"_"+item.getPurchaseCode()
|
||||
+"_"+item.getMakeCode()+"_"+item.getMaterialType()
|
||||
+"_"+item.getEndFace()+"_"+item.getPressureLevel();
|
||||
if (firstStage) {
|
||||
if (ExcelUtil2.getCellValue(row.getCell(13)).equals("")){
|
||||
// throw new RuntimeException("本次采购量不能为空");
|
||||
@@ -1022,23 +1041,13 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
}else if (nowCount != null){
|
||||
count = nowCount;
|
||||
} else {
|
||||
String diameterSStr = item.getDiameterS()==null?"null":item.getDiameterS().stripTrailingZeros().toString();
|
||||
String diameterLStr = item.getDiameterL()==null?"null":item.getDiameterL().stripTrailingZeros().toString();
|
||||
String wallThicknessSStr = item.getWallThicknessS()==null?"null":item.getWallThicknessS();
|
||||
String wallThicknessLStr = item.getWallThicknessL()==null?"null":item.getWallThicknessL();
|
||||
String str = item.getName()+"_"+item.getProductId()+"_"+diameterSStr
|
||||
+"_"+diameterLStr+"_"+wallThicknessSStr+"_"+item.getShortDescription()
|
||||
+"_"+wallThicknessLStr+"_"+item.getMaterial()
|
||||
+"_"+item.getMemo()+"_"+item.getSize()
|
||||
+"_"+item.getSpecialRequest()+"_"+item.getInsulationCode()
|
||||
+"_"+item.getLineAccount()+"_"+item.getAreaAccount()
|
||||
+"_"+item.getSiteAccount()+"_"+item.getUnitAccount()
|
||||
+"_"+item.getProductCode()+"_"+item.getPurchaseCode()
|
||||
+"_"+item.getMakeCode()+"_"+item.getMaterialType()
|
||||
+"_"+item.getEndFace()+"_"+item.getPressureLevel();
|
||||
BigDecimal useCount = countMap.get(str);
|
||||
if (useCount!=null){
|
||||
if (useCount!=null && !ignoreLineAccountSubtractUseCountSet.contains(str)){
|
||||
count = needCount.subtract(useCount);
|
||||
if (BooleanUtils.isTrue(ignoreLineAccount)) {
|
||||
// 不考虑管线号的情况,只操作一次减去前阶段的采购量
|
||||
ignoreLineAccountSubtractUseCountSet.add(str);
|
||||
}
|
||||
} else {
|
||||
count = needCount;
|
||||
}
|
||||
@@ -1117,8 +1126,25 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
item.setExtraField8(value);
|
||||
}
|
||||
}
|
||||
item.setMaterialOrder(materialOrder);
|
||||
materialOrderItemService.save(item);
|
||||
boolean itemSave = true;
|
||||
// 不考虑管线号的情况下,料单项合并
|
||||
if (BooleanUtils.isTrue(ignoreLineAccount)) {
|
||||
MaterialOrderItem orderItem = ignoreLineAccountMergeItemMap.get(str);
|
||||
if (orderItem != null) {
|
||||
orderItem.setNeedCount(orderItem.getNeedCount().add(item.getNeedCount()));
|
||||
orderItem.setCount(orderItem.getCount().add(item.getCount()));
|
||||
orderItem.setTotalWeight(totalWeight == null ? (product.getgWeight()==null?BigDecimal.ZERO:product.getgWeight()).multiply(orderItem.getCount()) : totalWeight);
|
||||
materialOrderItemService.update(orderItem);
|
||||
itemSave = false;
|
||||
}
|
||||
}
|
||||
if (itemSave) {
|
||||
item.setMaterialOrder(materialOrder);
|
||||
materialOrderItemService.save(item);
|
||||
if (BooleanUtils.isTrue(ignoreLineAccount)) {
|
||||
ignoreLineAccountMergeItemMap.put(str, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (notFindFlag) {
|
||||
Cell notFindCell = ExcelUtil2.getOrCreateCell(row, 34);
|
||||
@@ -1204,7 +1230,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
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();
|
||||
+"_"+ MaterialOrderItemConsts.getPrevStageLineAccount(materialOrder.getIgnoreLineAccount(), prevItem.getLineAccount()) +"_"+prevItem.getProductCode();
|
||||
if (!prevMap.containsKey(str)){
|
||||
prevMap.put(str,prevItem.getCount());
|
||||
prevMapM.put(str,prevItem);
|
||||
@@ -1300,7 +1326,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
materialOrderItem.setAreaAccount(entry.getValue().getAreaAccount());
|
||||
materialOrderItem.setUnitAccount(entry.getValue().getUnitAccount());
|
||||
materialOrderItem.setSiteAccount(entry.getValue().getSiteAccount());
|
||||
materialOrderItem.setLineAccount(entry.getValue().getLineAccount());
|
||||
materialOrderItem.setLineAccount(MaterialOrderItemConsts.getPrevStageLineAccount(materialOrder.getIgnoreLineAccount(), entry.getValue().getLineAccount()));
|
||||
materialOrderItem.setCodeType(entry.getValue().getCodeType());
|
||||
materialOrderItem.setProductCode(entry.getValue().getProductCode());
|
||||
materialOrderItem.setShortDescription(entry.getValue().getShortDescription());
|
||||
@@ -1336,7 +1362,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
map.put("name",entry.getValue().getName());
|
||||
map.put("unit",entry.getValue().getUnitAccount());
|
||||
map.put("site",entry.getValue().getSiteAccount());
|
||||
map.put("line",entry.getValue().getLineAccount());
|
||||
map.put("line", MaterialOrderItemConsts.getPrevStageLineAccount(materialOrder.getIgnoreLineAccount(), entry.getValue().getLineAccount()));
|
||||
map.put("code",entry.getValue().getProductCode());
|
||||
map.put("longDescription",entry.getValue().getLongDescription());
|
||||
map.put("needCount",' ');
|
||||
|
||||
@@ -80,6 +80,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="submitBody-row">
|
||||
<div class="submitBody-row-position">
|
||||
<div class="input-wrapper required">
|
||||
<label>是否考虑管线号</label>
|
||||
<select id="ignoreLineAccount" name="ignoreLineAccount" data-init="false">
|
||||
<option value="false">是</option>
|
||||
<option value="true">否</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input hidden name="progressId" id="progressId" th:value="${progressId}"/>
|
||||
<div class="formBtns formBtnsExtra">
|
||||
@@ -107,6 +118,10 @@
|
||||
Dialog.error("阶段不能为空");
|
||||
return;
|
||||
}
|
||||
if ($("#ignoreLineAccount").val() == null ||$("#ignoreLineAccount").val() == "null"){
|
||||
Dialog.error("是否考虑管线号不能为空");
|
||||
return;
|
||||
}
|
||||
if (!check()) {
|
||||
Dialog.error("请选择Excel文件");
|
||||
} else {
|
||||
@@ -122,6 +137,7 @@
|
||||
fromData.append("stage", $("#stage").val());
|
||||
fromData.append("memo", $("#memo").val());
|
||||
fromData.append("name", $("#name").val());
|
||||
fromData.append("ignoreLineAccount", $("#ignoreLineAccount").val());
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
cache: false,
|
||||
|
||||
Reference in New Issue
Block a user