|
@@ -2,13 +2,11 @@ package com.management.platform.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
-import com.management.platform.entity.vo.SysRichFunction;
|
|
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.service.*;
|
|
import com.management.platform.service.*;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -16,7 +14,6 @@ import com.management.platform.util.DateTimeUtil;
|
|
import com.management.platform.util.ExcelUtil;
|
|
import com.management.platform.util.ExcelUtil;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.MessageUtils;
|
|
import com.management.platform.util.MessageUtils;
|
|
-import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
@@ -27,9 +24,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -37,15 +33,12 @@ import javax.servlet.http.HttpServletRequest;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
-import java.sql.Wrapper;
|
|
|
|
import java.text.NumberFormat;
|
|
import java.text.NumberFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
-import java.time.Instant;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
-import java.time.LocalTime;
|
|
|
|
-import java.time.ZoneId;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -226,6 +219,15 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
List<Integer> totalIds = totals.stream().map(PlanProcedureTotal::getId).collect(Collectors.toList());
|
|
List<Integer> totalIds = totals.stream().map(PlanProcedureTotal::getId).collect(Collectors.toList());
|
|
boolean b = procedureTeams.stream().anyMatch(p -> totalIds.contains(p.getPlanProcedureId()));
|
|
boolean b = procedureTeams.stream().anyMatch(p -> totalIds.contains(p.getPlanProcedureId()));
|
|
rs.setHasAllocation(b?1:0);
|
|
rs.setHasAllocation(b?1:0);
|
|
|
|
+ AtomicBoolean allAllocation= new AtomicBoolean(true);
|
|
|
|
+ totals.forEach(t->{
|
|
|
|
+ Optional<ProdProcedureTeam> team = procedureTeams.stream().filter(p -> p.getPlanProcedureId().equals(t.getId())).findFirst();
|
|
|
|
+ if(!team.isPresent()){
|
|
|
|
+ allAllocation.set(false);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ rs.setHasAllocation(b?1:0);
|
|
|
|
+ rs.setHasAllAllocation(allAllocation.get()?1:0);
|
|
}
|
|
}
|
|
if(planType==2){
|
|
if(planType==2){
|
|
totals.forEach(ps->{
|
|
totals.forEach(ps->{
|
|
@@ -308,9 +310,11 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
plan.setTaskTypeName(taskType.getTaskTypeName());
|
|
plan.setTaskTypeName(taskType.getTaskTypeName());
|
|
}
|
|
}
|
|
List<ProdProcedure> procedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().eq("company_id", companyId).eq("product_id",plan.getProductId()).orderByDesc("id"));
|
|
List<ProdProcedure> procedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().eq("company_id", companyId).eq("product_id",plan.getProductId()).orderByDesc("id"));
|
|
- if(procedureList.size()<=0){
|
|
|
|
- msg.setError("当前产品工序配置未完成,请先完成工序配置");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ if(plan.getPlanType()==0){
|
|
|
|
+ if(procedureList.size()<=0){
|
|
|
|
+ msg.setError("当前产品工序配置未完成,请先完成工序配置");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
List<PlanProcedureTotal> planProcedureTotals=new ArrayList<>();
|
|
List<PlanProcedureTotal> planProcedureTotals=new ArrayList<>();
|
|
List<PlanProcedureTotal> oldPlanProcedureTotals=new ArrayList<>();
|
|
List<PlanProcedureTotal> oldPlanProcedureTotals=new ArrayList<>();
|
|
@@ -511,7 +515,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg importData(MultipartFile multipartFile, Integer planType) {
|
|
|
|
|
|
+ public HttpRespMsg importData(MultipartFile multipartFile, Integer planType){
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|
@@ -560,8 +564,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
if(planType!=2){
|
|
if(planType!=2){
|
|
if(!StringUtils.isEmpty(cell0.getStringCellValue())){
|
|
if(!StringUtils.isEmpty(cell0.getStringCellValue())){
|
|
if(cell0.getStringCellValue().equals("任务变更通知号")){
|
|
if(cell0.getStringCellValue().equals("任务变更通知号")){
|
|
- msg.setError("导入模板为插单计划模板,请重新下载模板");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("导入模板为插单计划模板,请重新下载模板");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
plan.setPlanType(0);
|
|
plan.setPlanType(0);
|
|
@@ -587,14 +590,13 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
if (describtionCell != null) describtionCell.setCellType(CellType.STRING);
|
|
if (describtionCell != null) describtionCell.setCellType(CellType.STRING);
|
|
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){
|
|
|
|
- msg.setError("已存在的排产工单号"+productSchedulingNumCell.getStringCellValue());
|
|
|
|
- return msg;
|
|
|
|
|
|
+ Plan one = getOne(new QueryWrapper<Plan>().eq("product_scheduling_num", productSchedulingNumCell.getStringCellValue()));
|
|
|
|
+ if(one!=null){
|
|
|
|
+ plan.setId(one.getId());
|
|
}
|
|
}
|
|
Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getProductSchedulingNum().equals(productSchedulingNumCell.getStringCellValue())).findFirst();
|
|
Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getProductSchedulingNum().equals(productSchedulingNumCell.getStringCellValue())).findFirst();
|
|
if(first.isPresent()){
|
|
if(first.isPresent()){
|
|
- msg.setError("重复的排产工单号"+productSchedulingNumCell.getStringCellValue());
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("重复的排产工单号"+productSchedulingNumCell.getStringCellValue());
|
|
}
|
|
}
|
|
plan.setProductSchedulingNum(productSchedulingNumCell.getStringCellValue());
|
|
plan.setProductSchedulingNum(productSchedulingNumCell.getStringCellValue());
|
|
}
|
|
}
|
|
@@ -604,8 +606,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
for (String s : split) {
|
|
for (String s : split) {
|
|
String[] targetSplit = s.split(",");
|
|
String[] targetSplit = s.split(",");
|
|
if(targetSplit.length!=2){
|
|
if(targetSplit.length!=2){
|
|
- msg.setError("数据["+s+"]钢印号数组及下标错误");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("数据["+s+"]钢印号数组及下标错误");
|
|
}
|
|
}
|
|
String steelStampNum=targetSplit[0];
|
|
String steelStampNum=targetSplit[0];
|
|
String indexNum=targetSplit[1];
|
|
String indexNum=targetSplit[1];
|
|
@@ -621,8 +622,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
if(indexNum.contains("-")){
|
|
if(indexNum.contains("-")){
|
|
String[] split2 = indexNum.split("-");
|
|
String[] split2 = indexNum.split("-");
|
|
if(Integer.valueOf(split2[0])>Integer.valueOf(split2[1])){
|
|
if(Integer.valueOf(split2[0])>Integer.valueOf(split2[1])){
|
|
- msg.setError("钢印号数组["+s+"]下标异常,第一下标不能大于第二下标");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("钢印号数组["+s+"]下标异常,第一下标不能大于第二下标");
|
|
}
|
|
}
|
|
p.setRuleIndexStart(Integer.valueOf(split2[0]));
|
|
p.setRuleIndexStart(Integer.valueOf(split2[0]));
|
|
p.setRuleIndexEnd(Integer.valueOf(split2[1]));
|
|
p.setRuleIndexEnd(Integer.valueOf(split2[1]));
|
|
@@ -640,12 +640,10 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
plan.setProductName(first.get().getName());
|
|
plan.setProductName(first.get().getName());
|
|
plan.setProjectCode(first.get().getCode());
|
|
plan.setProjectCode(first.get().getCode());
|
|
}else {
|
|
}else {
|
|
- msg.setError("产品["+productNameCell.getStringCellValue()+"]不存在");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("产品["+productNameCell.getStringCellValue()+"]不存在");
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- msg.setError("产品名称不能为空");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("产品名称不能为空");
|
|
}
|
|
}
|
|
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());
|
|
@@ -660,19 +658,16 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
plan.setForemanName(user.get().getName());
|
|
plan.setForemanName(user.get().getName());
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- msg.setError("工位["+stationNameCell.getStringCellValue()+"]不存在");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("工位["+stationNameCell.getStringCellValue()+"]不存在");
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- msg.setError("工位不能为空");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("工位不能为空");
|
|
}
|
|
}
|
|
if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())&&endDateCell!=null&&!StringUtils.isEmpty(endDateCell.getDateCellValue())){
|
|
if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())&&endDateCell!=null&&!StringUtils.isEmpty(endDateCell.getDateCellValue())){
|
|
LocalDate startDate = LocalDate.parse(sdf.format(startDateCell.getDateCellValue()), df);
|
|
LocalDate startDate = LocalDate.parse(sdf.format(startDateCell.getDateCellValue()), df);
|
|
LocalDate endDate = LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), df);
|
|
LocalDate endDate = LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), df);
|
|
if(endDate.isBefore(startDate)){
|
|
if(endDate.isBefore(startDate)){
|
|
- msg.setError("第"+rowIndex+"行数据结束日期大于开始日期");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("第"+rowIndex+"行数据结束日期大于开始日期");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())){
|
|
if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())){
|
|
@@ -687,8 +682,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
}else {
|
|
}else {
|
|
if(!StringUtils.isEmpty(cell0.getStringCellValue())){
|
|
if(!StringUtils.isEmpty(cell0.getStringCellValue())){
|
|
if(cell0.getStringCellValue().equals("排产工单号")){
|
|
if(cell0.getStringCellValue().equals("排产工单号")){
|
|
- msg.setError("导入模板为排产计划模板,请重新下载模板");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("导入模板为排产计划模板,请重新下载模板");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
plan.setPlanType(1);
|
|
plan.setPlanType(1);
|
|
@@ -723,14 +717,13 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
List<TaskType> taskTypeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", companyId));
|
|
List<TaskType> taskTypeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", companyId));
|
|
|
|
|
|
if(taskChangeNoticeNumCell!=null){
|
|
if(taskChangeNoticeNumCell!=null){
|
|
- if(count(new QueryWrapper<Plan>().eq("task_change_notice_num",taskChangeNoticeNumCell.getStringCellValue()))>0){
|
|
|
|
- msg.setError("已存在的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
|
|
|
|
- return msg;
|
|
|
|
|
|
+ Plan one = getOne(new QueryWrapper<Plan>().eq("task_change_notice_num", taskChangeNoticeNumCell.getStringCellValue()));
|
|
|
|
+ if(one!=null){
|
|
|
|
+ plan.setId(one.getId());
|
|
}
|
|
}
|
|
Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getTaskChangeNoticeNum().equals(taskChangeNoticeNumCell.getStringCellValue())).findFirst();
|
|
Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getTaskChangeNoticeNum().equals(taskChangeNoticeNumCell.getStringCellValue())).findFirst();
|
|
if(first.isPresent()){
|
|
if(first.isPresent()){
|
|
- msg.setError("重复的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("重复的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
|
|
}
|
|
}
|
|
plan.setTaskChangeNoticeNum(taskChangeNoticeNumCell.getStringCellValue());
|
|
plan.setTaskChangeNoticeNum(taskChangeNoticeNumCell.getStringCellValue());
|
|
}
|
|
}
|
|
@@ -775,19 +768,16 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
plan.setForemanName(user.get().getName());
|
|
plan.setForemanName(user.get().getName());
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- msg.setError("工位["+stationNameCell.getStringCellValue()+"]不存在");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("工位["+stationNameCell.getStringCellValue()+"]不存在");
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- msg.setError("工位不能为空");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("工位不能为空");
|
|
}
|
|
}
|
|
if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())&&endDateCell!=null&&!StringUtils.isEmpty(endDateCell.getDateCellValue())){
|
|
if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())&&endDateCell!=null&&!StringUtils.isEmpty(endDateCell.getDateCellValue())){
|
|
LocalDate startDate = LocalDate.parse(sdf.format(startDateCell.getDateCellValue()), df);
|
|
LocalDate startDate = LocalDate.parse(sdf.format(startDateCell.getDateCellValue()), df);
|
|
LocalDate endDate = LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), df);
|
|
LocalDate endDate = LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), df);
|
|
if(endDate.isBefore(startDate)){
|
|
if(endDate.isBefore(startDate)){
|
|
- msg.setError("第"+rowIndex+"行数据结束日期大于开始日期");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ throw new Exception("第"+rowIndex+"行数据结束日期大于开始日期");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())){
|
|
if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())){
|
|
@@ -876,7 +866,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
if(lastPlanList.size()>0){
|
|
if(lastPlanList.size()>0){
|
|
saveOrUpdateBatch(lastPlanList);
|
|
saveOrUpdateBatch(lastPlanList);
|
|
};
|
|
};
|
|
- msg.setData("导入成功,其中产品["+sb.toString()+"]产品工序未完成,请完成工序配置");
|
|
|
|
|
|
+ msg.setData("导入成功,其中产品["+sb.toString()+"]产品工序未完成,请完成工序配置后重新导入");
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -896,6 +886,8 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
return msg;
|
|
return msg;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ //针对try-catch 捕捉异常导致事务回滚失效的情况 手动设置回滚
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
//msg.setError("上传失败:" + e.getMessage());
|
|
//msg.setError("上传失败:" + e.getMessage());
|
|
msg.setError(MessageUtils.message("file.uploadError",e.getMessage()));
|
|
msg.setError(MessageUtils.message("file.uploadError",e.getMessage()));
|
|
return msg;
|
|
return msg;
|