|
@@ -387,6 +387,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
List<Product> productList = productMapper.selectList(new QueryWrapper<Product>().eq("company_id", companyId));
|
|
List<Product> productList = productMapper.selectList(new QueryWrapper<Product>().eq("company_id", companyId));
|
|
|
|
+ List<ProdProcedure> allProcedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().eq("company_id", companyId).orderByDesc("id"));
|
|
List<Plan> needInsertList=new ArrayList<>();
|
|
List<Plan> needInsertList=new ArrayList<>();
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
@@ -405,16 +406,18 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
XSSFCell productSchedulingNumCell = row.getCell(0);
|
|
XSSFCell productSchedulingNumCell = row.getCell(0);
|
|
XSSFCell productNameCell = row.getCell(1);
|
|
XSSFCell productNameCell = row.getCell(1);
|
|
XSSFCell steelStampNumberCell = row.getCell(2);
|
|
XSSFCell steelStampNumberCell = row.getCell(2);
|
|
- XSSFCell numCell = row.getCell(3);
|
|
|
|
- XSSFCell mainProcessCell = row.getCell(4);
|
|
|
|
- XSSFCell stationNameCell = row.getCell(5);
|
|
|
|
- XSSFCell startDateCell = row.getCell(6);
|
|
|
|
- XSSFCell endDateCell = row.getCell(7);
|
|
|
|
- XSSFCell describtionCell = row.getCell(8);
|
|
|
|
|
|
+ XSSFCell progressCell = row.getCell(3);
|
|
|
|
+ XSSFCell numCell = row.getCell(4);
|
|
|
|
+ XSSFCell mainProcessCell = row.getCell(5);
|
|
|
|
+ XSSFCell stationNameCell = row.getCell(6);
|
|
|
|
+ XSSFCell startDateCell = row.getCell(7);
|
|
|
|
+ XSSFCell endDateCell = row.getCell(8);
|
|
|
|
+ XSSFCell describtionCell = row.getCell(9);
|
|
|
|
|
|
if (productSchedulingNumCell != null) productSchedulingNumCell.setCellType(CellType.STRING);
|
|
if (productSchedulingNumCell != null) productSchedulingNumCell.setCellType(CellType.STRING);
|
|
if (productNameCell != null) productNameCell.setCellType(CellType.STRING);
|
|
if (productNameCell != null) productNameCell.setCellType(CellType.STRING);
|
|
if (steelStampNumberCell != null) steelStampNumberCell.setCellType(CellType.STRING);
|
|
if (steelStampNumberCell != null) steelStampNumberCell.setCellType(CellType.STRING);
|
|
|
|
+ if (progressCell != null) progressCell.setCellType(CellType.STRING);
|
|
if (numCell != null) numCell.setCellType(CellType.NUMERIC);
|
|
if (numCell != null) numCell.setCellType(CellType.NUMERIC);
|
|
if (mainProcessCell != null) mainProcessCell.setCellType(CellType.STRING);
|
|
if (mainProcessCell != null) mainProcessCell.setCellType(CellType.STRING);
|
|
if (stationNameCell != null) stationNameCell.setCellType(CellType.STRING);
|
|
if (stationNameCell != null) stationNameCell.setCellType(CellType.STRING);
|
|
@@ -424,11 +427,13 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
plan.setStartDate(planType==0?LocalDate.now():LocalDate.now().plusDays(1));
|
|
plan.setStartDate(planType==0?LocalDate.now():LocalDate.now().plusDays(1));
|
|
if(productSchedulingNumCell!=null){
|
|
if(productSchedulingNumCell!=null){
|
|
if(count(new QueryWrapper<Plan>().eq("product_scheduling_num",productSchedulingNumCell.getStringCellValue()))>0){
|
|
if(count(new QueryWrapper<Plan>().eq("product_scheduling_num",productSchedulingNumCell.getStringCellValue()))>0){
|
|
- Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getTaskChangeNoticeNum().equals(productSchedulingNumCell.getStringCellValue())).findFirst();
|
|
|
|
- if(first.isPresent()){
|
|
|
|
- msg.setError("已存在的排产工单号"+productSchedulingNumCell.getStringCellValue());
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
+ msg.setError("已存在的排产工单号"+productSchedulingNumCell.getStringCellValue());
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getProductSchedulingNum().equals(productSchedulingNumCell.getStringCellValue())).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ msg.setError("重复的排产工单号"+productSchedulingNumCell.getStringCellValue());
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
plan.setProductSchedulingNum(productSchedulingNumCell.getStringCellValue());
|
|
plan.setProductSchedulingNum(productSchedulingNumCell.getStringCellValue());
|
|
}
|
|
}
|
|
@@ -437,10 +442,14 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
if(first.isPresent()){
|
|
if(first.isPresent()){
|
|
plan.setProductId(first.get().getId());
|
|
plan.setProductId(first.get().getId());
|
|
plan.setProductName(first.get().getName());
|
|
plan.setProductName(first.get().getName());
|
|
|
|
+ plan.setProjectCode(first.get().getCode());
|
|
}else {
|
|
}else {
|
|
msg.setError("产品["+productNameCell.getStringCellValue()+"]不存在");
|
|
msg.setError("产品["+productNameCell.getStringCellValue()+"]不存在");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+ }else {
|
|
|
|
+ msg.setError("产品名称不能为空");
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
if(steelStampNumberCell!=null){
|
|
if(steelStampNumberCell!=null){
|
|
String value = steelStampNumberCell.getStringCellValue();
|
|
String value = steelStampNumberCell.getStringCellValue();
|
|
@@ -453,6 +462,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
msg.setError("钢印号不能为空");
|
|
msg.setError("钢印号不能为空");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+ plan.setProgress(progressCell==null?"":progressCell.getStringCellValue());
|
|
plan.setNum(numCell==null?0:Double.valueOf(numCell.getNumericCellValue()).intValue());
|
|
plan.setNum(numCell==null?0:Double.valueOf(numCell.getNumericCellValue()).intValue());
|
|
plan.setMainProcess(mainProcessCell==null?"":mainProcessCell.getStringCellValue());
|
|
plan.setMainProcess(mainProcessCell==null?"":mainProcessCell.getStringCellValue());
|
|
if(stationNameCell!=null){
|
|
if(stationNameCell!=null){
|
|
@@ -514,11 +524,13 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
|
|
|
|
if(taskChangeNoticeNumCell!=null){
|
|
if(taskChangeNoticeNumCell!=null){
|
|
if(count(new QueryWrapper<Plan>().eq("product_scheduling_num",taskChangeNoticeNumCell.getStringCellValue()))>0){
|
|
if(count(new QueryWrapper<Plan>().eq("product_scheduling_num",taskChangeNoticeNumCell.getStringCellValue()))>0){
|
|
- Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getTaskChangeNoticeNum().equals(taskChangeNoticeNumCell.getStringCellValue())).findFirst();
|
|
|
|
- if(first.isPresent()){
|
|
|
|
- msg.setError("已存在的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
+ msg.setError("已存在的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getTaskChangeNoticeNum().equals(taskChangeNoticeNumCell.getStringCellValue())).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ msg.setError("重复的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
plan.setTaskChangeNoticeNum(taskChangeNoticeNumCell.getStringCellValue());
|
|
plan.setTaskChangeNoticeNum(taskChangeNoticeNumCell.getStringCellValue());
|
|
}
|
|
}
|
|
@@ -581,7 +593,51 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
needInsertList.add(plan);
|
|
needInsertList.add(plan);
|
|
}
|
|
}
|
|
if(needInsertList.size()>0){
|
|
if(needInsertList.size()>0){
|
|
- saveBatch(needInsertList);
|
|
|
|
|
|
+ if(saveBatch(needInsertList)){
|
|
|
|
+ List<PlanProcedureTotal> planProcedureTotals=new ArrayList<>();
|
|
|
|
+ for (Plan plan : needInsertList) {
|
|
|
|
+ if(plan.getPlanType()==0){
|
|
|
|
+ //处理工序 获取当前产品最新版本的工序的版本号
|
|
|
|
+ List<ProdProcedure> procedureList = allProcedureList.stream().filter(al -> al.getProductId().equals(plan.getProductId())).collect(Collectors.toList());
|
|
|
|
+ if(procedureList!=null&&procedureList.size()>0){
|
|
|
|
+ String versionNumber = procedureList.get(0).getVersionNumber();
|
|
|
|
+ plan.setVersionNumber(versionNumber);
|
|
|
|
+ }
|
|
|
|
+ List<ProdProcedure> list = procedureList.stream().filter(pl -> pl.getVersionNumber().equals(procedureList.get(0).getVersionNumber())).collect(Collectors.toList());
|
|
|
|
+ list=list.stream().sorted(Comparator.comparing(ProdProcedure::getId)).collect(Collectors.toList());
|
|
|
|
+ for (ProdProcedure prodProcedure : list) {
|
|
|
|
+ PlanProcedureTotal p=new PlanProcedureTotal();
|
|
|
|
+ p.setPlanId(plan.getId());
|
|
|
|
+ p.setProdProcedureId(prodProcedure.getId());
|
|
|
|
+ BigDecimal totalWages=new BigDecimal(String.valueOf(prodProcedure.getUnitPrice()));
|
|
|
|
+ totalWages=totalWages.multiply(new BigDecimal(plan.getNum()));
|
|
|
|
+ p.setTotalWages(totalWages.doubleValue());
|
|
|
|
+ BigDecimal totalWorkingHours=new BigDecimal(String.valueOf(prodProcedure.getWorkingTime()));
|
|
|
|
+ totalWorkingHours=totalWorkingHours.multiply(new BigDecimal(plan.getNum()));
|
|
|
|
+ p.setTotalWorkingHours(totalWorkingHours.doubleValue());
|
|
|
|
+ planProcedureTotals.add(p);
|
|
|
|
+ }
|
|
|
|
+ planProcedureTotalService.saveBatch(planProcedureTotals);
|
|
|
|
+ List<PlanProcedureTotal> totals = planProcedureTotals.stream().filter(ps -> ps.getPlanId().equals(plan.getId())).collect(Collectors.toList());
|
|
|
|
+ if(totals.size()>0){
|
|
|
|
+ double sum = totals.stream().filter(t->t.getTotalWages()!=null).mapToDouble(PlanProcedureTotal::getTotalWages).sum();
|
|
|
|
+ plan.setPlanTotalWages(new BigDecimal(sum));
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ PlanProcedureTotal p=new PlanProcedureTotal();
|
|
|
|
+ p.setPlanId(plan.getId());
|
|
|
|
+ BigDecimal bigDecimal=new BigDecimal(String.valueOf(plan.getMoneyOfJob()));
|
|
|
|
+ bigDecimal=bigDecimal.multiply(new BigDecimal(String.valueOf(plan.getPlanWorkHour())));
|
|
|
|
+ p.setTotalWages(bigDecimal.doubleValue());
|
|
|
|
+ p.setTotalWorkingHours(plan.getPlanWorkHour());
|
|
|
|
+ planProcedureTotals.add(p);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ planProcedureTotalService.saveBatch(planProcedureTotals);
|
|
|
|
+ saveOrUpdateBatch(needInsertList);
|
|
|
|
+ }else {
|
|
|
|
+ msg.setError("验证失败");
|
|
|
|
+ };
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|