|
@@ -22,6 +22,7 @@ import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
@@ -55,6 +56,8 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
|
@Resource
|
|
|
private PlanMapper planMapper;
|
|
|
@Resource
|
|
|
+ private CompanyMapper companyMapper;
|
|
|
+ @Resource
|
|
|
private WxCorpInfoService wxCorpInfoService;
|
|
|
@Resource
|
|
|
private HttpServletRequest request;
|
|
@@ -74,28 +77,35 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
|
private ProductMapper productMapper;
|
|
|
@Resource
|
|
|
private PlanMaterialMapper planMaterialMapper;
|
|
|
+ @Resource
|
|
|
+ private TaskTypeMapper taskTypeMapper;
|
|
|
+
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
+ private String path;
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg getList(String date, String steelStampNumber, Integer planType,Integer deptId,Integer pageIndex,Integer pageSize) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
QueryWrapper<Plan> queryWrapper=new QueryWrapper();
|
|
|
DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- if(planType==0){
|
|
|
- queryWrapper.eq("start_date",LocalDate.now());
|
|
|
- }else if(planType==1){
|
|
|
- queryWrapper.eq("start_date",LocalDate.now().plusDays(1));
|
|
|
+ queryWrapper.eq("company_id",companyId);
|
|
|
+ if(planType!=2){
|
|
|
+ queryWrapper.eq("plan_type",0);
|
|
|
}else {
|
|
|
- queryWrapper.eq("plan_type",planType);
|
|
|
+ queryWrapper.eq("plan_type",1);
|
|
|
}
|
|
|
if(planType!=2){
|
|
|
queryWrapper.eq("station_id",deptId);
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(date)){
|
|
|
LocalDate parse = LocalDate.parse(date,df);
|
|
|
- queryWrapper.eq("plan_date",parse);
|
|
|
+ queryWrapper.eq("start_date",parse);
|
|
|
}else {
|
|
|
- LocalDate now = LocalDate.now();
|
|
|
- queryWrapper.eq("plan_date",planType==0?now:now.plusDays(1));
|
|
|
+ if(planType!=2){
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ queryWrapper.eq("start_date",planType==0?now:now.plusDays(1));
|
|
|
+ }
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(steelStampNumber)){
|
|
|
queryWrapper.gt("steel_stamp_number_start",steelStampNumber);
|
|
@@ -121,25 +131,37 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
|
if(plan.getProductId()!=null){
|
|
|
Product product = productMapper.selectById(plan.getProductId());
|
|
|
plan.setProductName(product.getName());
|
|
|
- }
|
|
|
+ }
|
|
|
if(plan.getId()==null){
|
|
|
- if(count(new QueryWrapper<Plan>().eq("product_scheduling_num",plan.getProductSchedulingNum()))>0){
|
|
|
- msg.setError("当前排产工单号已存在");
|
|
|
- return msg;
|
|
|
+ if(plan.getProductSchedulingNum()!=null){
|
|
|
+ if(count(new QueryWrapper<Plan>().eq("product_scheduling_num",plan.getProductSchedulingNum()))>0){
|
|
|
+ msg.setError("当前排产工单号已存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}
|
|
|
switch (plan.getPlanType()){
|
|
|
case 0:
|
|
|
- plan.setPlanDate(LocalDate.now());
|
|
|
+ plan.setStartDate(LocalDate.now());
|
|
|
break;
|
|
|
case 1:
|
|
|
- plan.setPlanDate(LocalDate.now().plusDays(1));
|
|
|
+ plan.setStartDate(LocalDate.now().plusDays(1));
|
|
|
break;
|
|
|
}
|
|
|
+ if(plan.getPlanType()!=2){
|
|
|
+ plan.setPlanType(0);
|
|
|
+ }else {
|
|
|
+ plan.setPlanType(1);
|
|
|
+ }
|
|
|
if(planMapper.insert(plan)<0){
|
|
|
msg.setError("验证失败");
|
|
|
return msg;
|
|
|
}
|
|
|
}else {
|
|
|
+ if(plan.getPlanType()!=2){
|
|
|
+ plan.setPlanType(0);
|
|
|
+ }else {
|
|
|
+ plan.setPlanType(1);
|
|
|
+ }
|
|
|
if(planMapper.updateById(plan)<0){
|
|
|
msg.setError("验证失败");
|
|
|
return msg;
|
|
@@ -184,6 +206,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
|
public HttpRespMsg importData(MultipartFile multipartFile, Integer planType) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String fileName = multipartFile.getOriginalFilename();
|
|
|
File file = new File(fileName == null ? "file" : fileName);
|
|
|
InputStream inputStream = null;
|
|
@@ -218,91 +241,187 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
|
continue;
|
|
|
}
|
|
|
- //部门 排产工单号 产品名称 钢印号 数量 主工序 工位 开工时间 完工时间 描述
|
|
|
- XSSFCell deptCell = row.getCell(0);
|
|
|
- XSSFCell productSchedulingNumCell = row.getCell(1);
|
|
|
- XSSFCell productNameCell = row.getCell(2);
|
|
|
- XSSFCell steelStampNumberCell = 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 (deptCell != null) deptCell.setCellType(CellType.STRING);
|
|
|
- if (productSchedulingNumCell != null) productSchedulingNumCell.setCellType(CellType.NUMERIC);
|
|
|
- if (productNameCell != null) productNameCell.setCellType(CellType.STRING);
|
|
|
- if (steelStampNumberCell != null) steelStampNumberCell.setCellType(CellType.STRING);
|
|
|
- if (numCell != null) numCell.setCellType(CellType.NUMERIC);
|
|
|
- if (mainProcessCell != null) mainProcessCell.setCellType(CellType.STRING);
|
|
|
- if (stationNameCell != null) stationNameCell.setCellType(CellType.STRING);
|
|
|
- if (startDateCell != null) startDateCell.setCellType(CellType.NUMERIC);
|
|
|
- if (endDateCell != null) endDateCell.setCellType(CellType.NUMERIC);
|
|
|
- if (describtionCell != null) describtionCell.setCellType(CellType.STRING);
|
|
|
Plan plan=new Plan();
|
|
|
- plan.setPlanDate(planType==0?LocalDate.now():LocalDate.now().plusDays(1));
|
|
|
- if(deptCell!=null){
|
|
|
- Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentName().equals(deptCell.getStringCellValue())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- plan.setStationId(first.get().getDepartmentId());
|
|
|
- plan.setStationName(first.get().getDepartmentName());
|
|
|
- }else {
|
|
|
- msg.setError("部门["+deptCell.getStringCellValue()+"]不存在");
|
|
|
- return msg;
|
|
|
+ plan.setCompanyId(companyId);
|
|
|
+ if(planType!=2){
|
|
|
+ plan.setPlanType(0);
|
|
|
+ //排产工单号 产品名称 钢印号 数量 主工序 工位 开工时间 完工时间 描述
|
|
|
+ XSSFCell productSchedulingNumCell = row.getCell(0);
|
|
|
+ XSSFCell productNameCell = row.getCell(1);
|
|
|
+ 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);
|
|
|
+
|
|
|
+ if (productSchedulingNumCell != null) productSchedulingNumCell.setCellType(CellType.STRING);
|
|
|
+ if (productNameCell != null) productNameCell.setCellType(CellType.STRING);
|
|
|
+ if (steelStampNumberCell != null) steelStampNumberCell.setCellType(CellType.STRING);
|
|
|
+ if (numCell != null) numCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (mainProcessCell != null) mainProcessCell.setCellType(CellType.STRING);
|
|
|
+ if (stationNameCell != null) stationNameCell.setCellType(CellType.STRING);
|
|
|
+ if (startDateCell != null) startDateCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (endDateCell != null) endDateCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (describtionCell != null) describtionCell.setCellType(CellType.STRING);
|
|
|
+ plan.setStartDate(planType==0?LocalDate.now():LocalDate.now().plusDays(1));
|
|
|
+ if(productSchedulingNumCell!=null){
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ plan.setProductSchedulingNum(productSchedulingNumCell.getStringCellValue());
|
|
|
}
|
|
|
- }else {
|
|
|
- msg.setError("部门不能为空");
|
|
|
- return msg;
|
|
|
- }
|
|
|
- if(productSchedulingNumCell!=null){
|
|
|
- if(count(new QueryWrapper<Plan>().eq("product_scheduling_num",productSchedulingNumCell.getStringCellValue()))>0){
|
|
|
- msg.setError("已存在的排产工单号"+productSchedulingNumCell.getStringCellValue());
|
|
|
+ if(productNameCell!=null){
|
|
|
+ Optional<Product> first = productList.stream().filter(pl -> pl.getName().equals(productNameCell.getStringCellValue())).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ plan.setProductId(first.get().getId());
|
|
|
+ plan.setProductName(first.get().getName());
|
|
|
+ }else {
|
|
|
+ msg.setError("产品["+productNameCell.getStringCellValue()+"]不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(steelStampNumberCell!=null){
|
|
|
+ String value = steelStampNumberCell.getStringCellValue();
|
|
|
+ String[] split = value.split("-");
|
|
|
+ if(split.length>1){
|
|
|
+ plan.setSteelStampNumberStart(split[0]);
|
|
|
+ plan.setSteelStampNumberEnd(split[1]);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ msg.setError("钢印号不能为空");
|
|
|
return msg;
|
|
|
}
|
|
|
- plan.setProductSchedulingNum(productSchedulingNumCell.getStringCellValue());
|
|
|
- }
|
|
|
- if(productNameCell!=null){
|
|
|
- Optional<Product> first = productList.stream().filter(pl -> pl.getName().equals(productNameCell.getStringCellValue())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- plan.setProductId(first.get().getId());
|
|
|
- plan.setProductName(first.get().getName());
|
|
|
+ plan.setNum(numCell==null?0:Double.valueOf(numCell.getNumericCellValue()).intValue());
|
|
|
+ plan.setMainProcess(mainProcessCell==null?"":mainProcessCell.getStringCellValue());
|
|
|
+ if(stationNameCell!=null){
|
|
|
+ Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentName().equals(stationNameCell.getStringCellValue())).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ plan.setStationId(first.get().getDepartmentId());
|
|
|
+ plan.setStationName(first.get().getDepartmentName());
|
|
|
+ Optional<User> user = userList.stream().filter(ul -> first.get().getManagerId() != null && ul.getId().equals(first.get().getManagerId())).findFirst();
|
|
|
+ if(user.isPresent()){
|
|
|
+ plan.setForemanId(user.get().getId());
|
|
|
+ plan.setForemanName(user.get().getName());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ msg.setError("工位["+stationNameCell.getStringCellValue()+"]不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}else {
|
|
|
- msg.setError("产品["+productNameCell.getStringCellValue()+"]不存在");
|
|
|
+ msg.setError("工位不能为空");
|
|
|
return msg;
|
|
|
}
|
|
|
- }
|
|
|
- if(steelStampNumberCell!=null){
|
|
|
- String value = steelStampNumberCell.getStringCellValue();
|
|
|
- String[] split = value.split("-");
|
|
|
- if(split.length>1){
|
|
|
- plan.setSteelStampNumberStart(split[0]);
|
|
|
- plan.setSteelStampNumberEnd(split[1]);
|
|
|
+ if(startDateCell!=null){
|
|
|
+ plan.setStartDate(planType==0?LocalDate.now():LocalDate.now().plusDays(1));
|
|
|
}
|
|
|
- }
|
|
|
- plan.setNum(numCell==null?0:Integer.valueOf(String.valueOf(numCell.getNumericCellValue())));
|
|
|
- plan.setMainProcess(mainProcessCell==null?"":mainProcessCell.getStringCellValue());
|
|
|
- if(stationNameCell!=null){
|
|
|
- Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentName().equals(stationNameCell.getStringCellValue())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- if(!first.get().getSuperiorId().equals(plan.getStationId())){
|
|
|
- msg.setError("工位["+stationNameCell.getStringCellValue()+"]不属于部门["+deptCell.getStringCellValue()+"]");
|
|
|
+ if(endDateCell!=null){
|
|
|
+ plan.setEndDate(LocalDate.parse(sdf.format(endDateCell.getDateCellValue()),df));
|
|
|
+ }
|
|
|
+ plan.setDescribtion(describtionCell==null?"":describtionCell.getStringCellValue());
|
|
|
+ }else {
|
|
|
+ plan.setPlanType(1);
|
|
|
+ /*插单计划*/
|
|
|
+ //任务变更通知号 任务名称 任务类型 计划人数 数量 计划工时 单价 质检类型 工位 开工时间 完工时间 描述
|
|
|
+ XSSFCell taskChangeNoticeNumCell = row.getCell(0);
|
|
|
+ XSSFCell taskNameCell = row.getCell(1);
|
|
|
+ XSSFCell taskTypeNameCell = row.getCell(2);
|
|
|
+ XSSFCell planManNumCell = row.getCell(3);
|
|
|
+ XSSFCell numCell = row.getCell(4);
|
|
|
+ XSSFCell planWorkHourCell = row.getCell(5);
|
|
|
+ XSSFCell moneyOfJobCell = row.getCell(6);
|
|
|
+ XSSFCell checkTypeCell = row.getCell(7);
|
|
|
+ XSSFCell stationNameCell = row.getCell(8);
|
|
|
+ XSSFCell startDateCell = row.getCell(9);
|
|
|
+ XSSFCell endDateCell = row.getCell(10);
|
|
|
+ XSSFCell describtionCell = row.getCell(11);
|
|
|
+
|
|
|
+ if (taskChangeNoticeNumCell != null) taskChangeNoticeNumCell.setCellType(CellType.STRING);
|
|
|
+ if (taskNameCell != null) taskNameCell.setCellType(CellType.STRING);
|
|
|
+ if (taskTypeNameCell != null) taskTypeNameCell.setCellType(CellType.STRING);
|
|
|
+ if (planManNumCell != null) planManNumCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (numCell != null) numCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (planWorkHourCell != null) planWorkHourCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (moneyOfJobCell != null) moneyOfJobCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (checkTypeCell != null) checkTypeCell.setCellType(CellType.STRING);
|
|
|
+ if (stationNameCell != null) stationNameCell.setCellType(CellType.STRING);
|
|
|
+ if (startDateCell != null) startDateCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (endDateCell != null) endDateCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (describtionCell != null) describtionCell.setCellType(CellType.STRING);
|
|
|
+
|
|
|
+ List<TaskType> taskTypeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", companyId));
|
|
|
+
|
|
|
+ if(taskChangeNoticeNumCell!=null){
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ plan.setTaskChangeNoticeNum(taskChangeNoticeNumCell.getStringCellValue());
|
|
|
+ }
|
|
|
+ if(taskNameCell!=null){
|
|
|
+ plan.setTaskName(taskNameCell.getStringCellValue());
|
|
|
+ }
|
|
|
+ if(taskTypeNameCell!=null){
|
|
|
+ Optional<TaskType> first = taskTypeList.stream().filter(tl -> tl.getTaskTypeName().equals(taskTypeNameCell.getStringCellValue())).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ plan.setTaskTypeId(first.get().getId());
|
|
|
+ plan.setTaskTypeName(first.get().getTaskTypeName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ plan.setPlanManNum(planManNumCell==null?0:Double.valueOf(planManNumCell.getNumericCellValue()).intValue());
|
|
|
+ plan.setNum(numCell==null?0:Double.valueOf(numCell.getNumericCellValue()).intValue());
|
|
|
+ plan.setPlanWorkHour(numCell==null?0:Double.valueOf(numCell.getNumericCellValue()));
|
|
|
+ if(moneyOfJobCell!=null){
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(moneyOfJobCell.getNumericCellValue());
|
|
|
+ plan.setMoneyOfJob(bigDecimal);
|
|
|
+ }
|
|
|
+ if(checkTypeCell!=null){
|
|
|
+ switch (taskTypeNameCell.getStringCellValue()){
|
|
|
+ case "自检":
|
|
|
+ plan.setCheckType(0);
|
|
|
+ break;
|
|
|
+ case "互检":
|
|
|
+ plan.setCheckType(1);
|
|
|
+ break;
|
|
|
+ case "专检":
|
|
|
+ plan.setCheckType(2);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(stationNameCell!=null){
|
|
|
+ Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentName().equals(stationNameCell.getStringCellValue())).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ plan.setStationId(first.get().getDepartmentId());
|
|
|
+ plan.setStationName(first.get().getDepartmentName());
|
|
|
+ Optional<User> user = userList.stream().filter(ul -> first.get().getManagerId() != null && ul.getId().equals(first.get().getManagerId())).findFirst();
|
|
|
+ if(user.isPresent()){
|
|
|
+ plan.setForemanId(user.get().getId());
|
|
|
+ plan.setForemanName(user.get().getName());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ msg.setError("工位["+stationNameCell.getStringCellValue()+"]不存在");
|
|
|
return msg;
|
|
|
}
|
|
|
- plan.setStationId(first.get().getDepartmentId());
|
|
|
- plan.setStationName(first.get().getDepartmentName());
|
|
|
}else {
|
|
|
- msg.setError("工位["+stationNameCell.getStringCellValue()+"]不存在");
|
|
|
+ msg.setError("工位不能为空");
|
|
|
return msg;
|
|
|
}
|
|
|
+ if(startDateCell!=null){
|
|
|
+ plan.setStartDate(LocalDate.parse(sdf.format(startDateCell.getDateCellValue()),df));
|
|
|
+ }
|
|
|
+ if(endDateCell!=null){
|
|
|
+ plan.setEndDate(LocalDate.parse(sdf.format(endDateCell.getDateCellValue()),df));
|
|
|
+ }
|
|
|
+ plan.setDescribtion(describtionCell==null?"":describtionCell.getStringCellValue());
|
|
|
}
|
|
|
- if(startDateCell!=null){
|
|
|
- plan.setStartDate(LocalDate.parse(startDateCell.getDateCellValue().toString(),df));
|
|
|
- }
|
|
|
- if(endDateCell!=null){
|
|
|
- plan.setEndDate(LocalDate.parse(endDateCell.getDateCellValue().toString(),df));
|
|
|
- }
|
|
|
- plan.setDescribtion(describtionCell==null?"":describtionCell.getStringCellValue());
|
|
|
needInsertList.add(plan);
|
|
|
}
|
|
|
if(needInsertList.size()>0){
|
|
@@ -343,12 +462,100 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
|
// file.deleteOnExit();//程序退出时删除临时文件
|
|
|
System.out.println(file.delete());
|
|
|
}
|
|
|
- return null;
|
|
|
+ return msg;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg exportData(String date, Integer planType) {
|
|
|
- return null;
|
|
|
+ public HttpRespMsg exportData(String date, Integer planType,String steelStampNumber) {
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ QueryWrapper<Plan> queryWrapper=new QueryWrapper();
|
|
|
+ DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ queryWrapper.eq("company_id",companyId);
|
|
|
+ if(planType!=2){
|
|
|
+ queryWrapper.eq("plan_type",0);
|
|
|
+ }else {
|
|
|
+ queryWrapper.eq("plan_type",1);
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(date)){
|
|
|
+ LocalDate parse = LocalDate.parse(date,df);
|
|
|
+ queryWrapper.eq("start_date",parse);
|
|
|
+ }else {
|
|
|
+ if(planType!=2){
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ queryWrapper.eq("start_date",planType==0?now:now.plusDays(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(steelStampNumber)){
|
|
|
+ queryWrapper.gt("steel_stamp_number_start",steelStampNumber);
|
|
|
+ queryWrapper.lt("steel_stamp_number_end",steelStampNumber);
|
|
|
+ }
|
|
|
+ List<Plan> planList = planMapper.selectList(queryWrapper);
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
+ if(planType!=2){
|
|
|
+ titleList.add("排产工单号");
|
|
|
+ titleList.add("产品名称");
|
|
|
+ titleList.add("项目代码");
|
|
|
+ titleList.add("钢印号");
|
|
|
+ titleList.add("数量");
|
|
|
+ titleList.add("主工序");
|
|
|
+ titleList.add("工位");
|
|
|
+ titleList.add("工长");
|
|
|
+ titleList.add("开工时间");
|
|
|
+ titleList.add("完工时间");
|
|
|
+ titleList.add("描述");
|
|
|
+ }else {
|
|
|
+ titleList.add("任务变更通知号");
|
|
|
+ titleList.add("任务名称");
|
|
|
+ titleList.add("任务类型");
|
|
|
+ titleList.add("计划人数");
|
|
|
+ titleList.add("数量");
|
|
|
+ titleList.add("计划工时");
|
|
|
+ titleList.add("单价");
|
|
|
+ titleList.add("质检类型");
|
|
|
+ titleList.add("工位");
|
|
|
+ titleList.add("工长");
|
|
|
+ titleList.add("开工时间");
|
|
|
+ titleList.add("完工时间");
|
|
|
+ titleList.add("描述");
|
|
|
+ }
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ dataList.add(titleList);
|
|
|
+ for (Plan plan : planList) {
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ if(planType!=2){
|
|
|
+ item.add(plan.getProductSchedulingNum());
|
|
|
+ item.add(plan.getProductName());
|
|
|
+ item.add(plan.getProjectCode());
|
|
|
+ item.add(plan.getSteelStampNumberStart()+"-"+plan.getSteelStampNumberEnd());
|
|
|
+ item.add(String.valueOf(plan.getNum()==null?"":plan.getNum()));
|
|
|
+ item.add(plan.getMainProcess()==null?"":plan.getMainProcess());
|
|
|
+ item.add(plan.getStationName());
|
|
|
+ item.add(plan.getForemanName()==null?"":plan.getForemanName());
|
|
|
+ item.add(df.format(plan.getStartDate()));
|
|
|
+ item.add(df.format(plan.getEndDate()));
|
|
|
+ item.add(plan.getDescribtion()==null?"":plan.getDescribtion());
|
|
|
+ }else {
|
|
|
+ item.add(plan.getTaskChangeNoticeNum());
|
|
|
+ item.add(plan.getTaskName());
|
|
|
+ item.add(plan.getTaskTypeName());
|
|
|
+ item.add(String.valueOf(plan.getPlanManNum()==null?"":plan.getPlanManNum()));
|
|
|
+ item.add(String.valueOf(plan.getNum()==null?"":plan.getNum()));
|
|
|
+ item.add(String.valueOf(plan.getPlanWorkHour()==null?"":plan.getPlanWorkHour()));
|
|
|
+ item.add(String.valueOf(plan.getMoneyOfJob()==null?"":plan.getMoneyOfJob()));
|
|
|
+ item.add(plan.getCheckType()==0?"自检":plan.getCheckType()==1?"互检":plan.getCheckType()==2?"专检":"");
|
|
|
+ item.add(plan.getStationName());
|
|
|
+ item.add(plan.getForemanName());
|
|
|
+ item.add(df.format(plan.getEndDate()));
|
|
|
+ item.add(plan.getDescribtion()==null?"":plan.getDescribtion());
|
|
|
+ }
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ Company company = companyMapper.selectById(companyId);
|
|
|
+ String fileName=(planType==0?"今日计划":planType==1?"明日计划":planType==1?"插单计划":"")+company.getCompanyName()+System.currentTimeMillis();
|
|
|
+ String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName, dataList, path);
|
|
|
+ msg.setData(resp);
|
|
|
+ return msg;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -380,23 +587,23 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
|
if(plan!=null){
|
|
|
switch (type){
|
|
|
case 0:
|
|
|
- List<ProdProcedure> prodProcedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().eq("product_id", plan.getProductId()));
|
|
|
+ List<ProdProcedure> prodProcedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().eq("product_id", plan.getProductId()).eq("version_number",plan.getVersionNumber()));
|
|
|
msg.setData(prodProcedureList);
|
|
|
break;
|
|
|
- case 1:
|
|
|
- Map map=new HashMap();
|
|
|
- List<ProdMaterial> prodMaterialList = prodMaterialMapper.selectList(new QueryWrapper<ProdMaterial>().eq("product_id", plan.getProductId()));
|
|
|
- List<PlanMaterial> planMaterialList = planMaterialMapper.selectList(new QueryWrapper<PlanMaterial>().eq("plan_id", plan.getId()));
|
|
|
- planMaterialList.forEach(pl->{
|
|
|
- Optional<ProdMaterial> first = prodMaterialList.stream().filter(pt -> pt.getId().equals(pl.getProdMaterialId())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- pl.setProdMaterial(first.get());
|
|
|
- }else pl.setProdMaterial(new ProdMaterial());
|
|
|
- });
|
|
|
- map.put("material",prodMaterialList);
|
|
|
- map.put("lackMaterial",planMaterialList);
|
|
|
- msg.setData(map);
|
|
|
- break;
|
|
|
+// case 1:
|
|
|
+// Map map=new HashMap();
|
|
|
+// List<ProdMaterial> prodMaterialList = prodMaterialMapper.selectList(new QueryWrapper<ProdMaterial>().eq("product_id", plan.getProductId()));
|
|
|
+// List<PlanMaterial> planMaterialList = planMaterialMapper.selectList(new QueryWrapper<PlanMaterial>().eq("plan_id", plan.getId()));
|
|
|
+// planMaterialList.forEach(pl->{
|
|
|
+// Optional<ProdMaterial> first = prodMaterialList.stream().filter(pt -> pt.getId().equals(pl.getProdMaterialId())).findFirst();
|
|
|
+// if(first.isPresent()){
|
|
|
+// pl.setProdMaterial(first.get());
|
|
|
+// }else pl.setProdMaterial(new ProdMaterial());
|
|
|
+// });
|
|
|
+// map.put("material",prodMaterialList);
|
|
|
+// map.put("lackMaterial",planMaterialList);
|
|
|
+// msg.setData(map);
|
|
|
+// break;
|
|
|
}
|
|
|
}
|
|
|
return msg;
|