|
|
|
|
@@ -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",' ');
|
|
|
|
|
|