|
@@ -28,6 +28,7 @@ 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.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.bind.annotation.RequestMapping;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -308,9 +309,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 +514,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 +563,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 +589,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 +605,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 +621,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 +639,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 +657,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 +681,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 +716,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 +767,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 +865,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 +885,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;
|