diff --git a/src/main/java/org/springblade/modules/business/contraller/DeviceController.java b/src/main/java/org/springblade/modules/business/contraller/DeviceController.java index 0c6e0c2..ee816ff 100644 --- a/src/main/java/org/springblade/modules/business/contraller/DeviceController.java +++ b/src/main/java/org/springblade/modules/business/contraller/DeviceController.java @@ -96,7 +96,7 @@ public class DeviceController extends BladeController { BladeUser user = AuthUtil.getUser(); if (!user.getRoleName().contains("administrator") && !user.getRoleName().contains("admin")) { - if(user.getRoleName().equals("客服") || user.getRoleName().equals("维修负责人")){ + if(user.getRoleName().equals("客服") || user.getRoleName().equals("维修负责人") || user.getRoleName().equals("维修人员")){ List deptIds = null; String deptId = user.getDeptId(); List deptList = deptService.list(Wrappers.lambdaQuery(Dept.class).eq(Dept::getParentId,deptId).eq(Dept::getIsDeleted,0)); diff --git a/src/main/java/org/springblade/modules/business/contraller/MaintenanceController.java b/src/main/java/org/springblade/modules/business/contraller/MaintenanceController.java index 6599a7d..f5a460e 100644 --- a/src/main/java/org/springblade/modules/business/contraller/MaintenanceController.java +++ b/src/main/java/org/springblade/modules/business/contraller/MaintenanceController.java @@ -343,12 +343,16 @@ public class MaintenanceController extends BladeController { List detailList = taskDto.getDetailList(); for (MaintenanceTaskDetail maintenanceTaskDetail : detailList) { Long id = maintenanceTaskDetail.getId(); - Optional> detailGoods = Optional.ofNullable(maintenanceTaskDetail.getDetailGoodsList()); - if (detailGoods.isPresent()) { - List detailGoodsList = detailGoods.get(); - for (MaintenanceTaskDetailGoods maintenanceTaskDetailGoods : detailGoodsList) { + List detailGoods = maintenanceTaskDetail.getDetailGoodsList(); + if (CollectionUtil.isNotEmpty(detailGoods)) { + for (MaintenanceTaskDetailGoods maintenanceTaskDetailGoods : detailGoods) { maintenanceTaskDetailGoods.setParentId(id); - maintenanceApplyGoodsService.save(maintenanceTaskDetailGoods); + if(maintenanceTaskDetailGoods.getId() == null){ + maintenanceApplyGoodsService.save(maintenanceTaskDetailGoods); + }else{ + maintenanceApplyGoodsService.updateById(maintenanceTaskDetailGoods); + } + } } else { taskDetailService.saveOrUpdate(maintenanceTaskDetail); diff --git a/src/main/java/org/springblade/modules/business/contraller/WorkBenchesController.java b/src/main/java/org/springblade/modules/business/contraller/WorkBenchesController.java index cc85bf9..a898258 100644 --- a/src/main/java/org/springblade/modules/business/contraller/WorkBenchesController.java +++ b/src/main/java/org/springblade/modules/business/contraller/WorkBenchesController.java @@ -195,10 +195,8 @@ public class WorkBenchesController extends BladeController { List deptIds = null; if (!user.getRoleName().contains("administrator") && !user.getRoleName().contains("admin")) { String deptId = user.getDeptId(); - List deptList = deptService.list(Wrappers.lambdaQuery(Dept.class).eq(Dept::getParentId,deptId).eq(Dept::getIsDeleted,0)); - if(CollectionUtil.isNotEmpty(deptList)){ - deptIds = deptList.stream().map(Dept::getId).map(x->x+"").collect(Collectors.toList()); - } + deptIds = new ArrayList<>(); + deptIds.add(deptId); } List fault = deviceService.selectTypeCount(startTime, endTime,deptIds); map.put("fault", fault); diff --git a/src/main/java/org/springblade/modules/business/contraller/supplies/ApplyController.java b/src/main/java/org/springblade/modules/business/contraller/supplies/ApplyController.java index 631ffdc..64ed2ea 100644 --- a/src/main/java/org/springblade/modules/business/contraller/supplies/ApplyController.java +++ b/src/main/java/org/springblade/modules/business/contraller/supplies/ApplyController.java @@ -77,6 +77,9 @@ public class ApplyController extends BladeController { wrapper.eq(Apply::getApplyUserId,user.getUserId()); } } + if(StringUtils.isNotEmpty(apply.getApplyUser())){ + wrapper.eq(Apply::getApplyUser,apply.getApplyUser()); + } IPage pages = applyService.page(Condition.getPage(query), wrapper); List records = pages.getRecords(); if (CollectionUtil.isNotEmpty(records)) { diff --git a/src/main/java/org/springblade/modules/business/contraller/supplies/GoodsController.java b/src/main/java/org/springblade/modules/business/contraller/supplies/GoodsController.java index c780a24..4e613e9 100644 --- a/src/main/java/org/springblade/modules/business/contraller/supplies/GoodsController.java +++ b/src/main/java/org/springblade/modules/business/contraller/supplies/GoodsController.java @@ -192,7 +192,7 @@ public class GoodsController extends BladeController { goodsExcel.setUnifiedQuotation(1275.00); goodsExcel.setWarnNum(85); goodsExcel.setRenewNum(13); - goodsExcel.setAllEnterNum(50); +// goodsExcel.setAllEnterNum(50); goodsExcel.setDeactivate("是"); goodsExcel.setRemark("备注"); list.add(goodsExcel); diff --git a/src/main/java/org/springblade/modules/business/excel/supplies/GoodsExcel.java b/src/main/java/org/springblade/modules/business/excel/supplies/GoodsExcel.java index 5dd624b..aa01269 100644 --- a/src/main/java/org/springblade/modules/business/excel/supplies/GoodsExcel.java +++ b/src/main/java/org/springblade/modules/business/excel/supplies/GoodsExcel.java @@ -35,19 +35,28 @@ public class GoodsExcel implements Serializable { @ExcelProperty("名称") private String name; + @ExcelProperty("物品大类") + private String bigClass; + @ExcelProperty("描述") private String describes; @ExcelProperty("产品型号") private String xh; + @ExcelProperty("参数") + private String rule; + @ExcelProperty("品牌") private String brand; + @ExcelProperty("单位") + private String unit; + @ExcelProperty("采购价格") private Double purchasePrice; - @ExcelProperty("在库数量") + @ExcelProperty("入库数量") private Integer num; // @ExcelProperty("库存价值") @@ -62,8 +71,8 @@ public class GoodsExcel implements Serializable { @ExcelProperty("续订时间") private Integer renewNum; - @ExcelProperty("实际入库数量") - private Integer allEnterNum; +// @ExcelProperty("实际入库数量") +// private Integer allEnterNum; @ExcelProperty("是否已停产?") private String deactivate; diff --git a/src/main/java/org/springblade/modules/business/pojo/vo/MessageVO.java b/src/main/java/org/springblade/modules/business/pojo/vo/MessageVO.java index 42198d3..2586e8c 100644 --- a/src/main/java/org/springblade/modules/business/pojo/vo/MessageVO.java +++ b/src/main/java/org/springblade/modules/business/pojo/vo/MessageVO.java @@ -17,4 +17,6 @@ public class MessageVO { private Integer status; private Integer messageType; + + private String requirementCode; } diff --git a/src/main/java/org/springblade/modules/business/service/impl/MaintenancePlanServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/MaintenancePlanServiceImpl.java index ff7325a..339b9a1 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/MaintenancePlanServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/MaintenancePlanServiceImpl.java @@ -246,7 +246,7 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl> listMap = planDetails.stream().collect(Collectors.groupingBy(MaintenancePlanDetail::getPlanId)); - SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); + SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); String todayStr = format.format(new Date()); int count = 1; int taskCount = 0; @@ -263,6 +263,9 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl taskList, HttpServletResponse response) throws IOException { - for (MaintenanceTask task : taskList) { - //数据获取 - String templateFile = "MaintenanceTaskReport.xlsx"; - InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFile); - FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); - Map map0 = new HashMap<>(); - map0.put("taskName", task.getDeptName()); - String period = baseMapper.findPeriod(); - map0.put("period",period + "度报告"); - map0.put("time", DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日")); - map0.put("taskCode", task.getTaskCode()); - - Map map1 = new HashMap<>(); - map1.put("taskName", task.getDeptName()); - map1.put("address", task.getDeptName()); - map1.put("taskContent", task.getTaskContent()); - - Map map2 = new HashMap<>(); - map2.put("taskName", task.getDeptName()); - map2.put("address", task.getDeptName()); - map2.put("inspectionConclusion", task.getInspectionConclusion()); - map2.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); - - //获取客户联系人、联系电话 - Map cusMap = baseMapper.getDeptContact(task.getDeptId()); - if(CollectionUtils.isNotEmpty(cusMap)){ - map2.put("contact",cusMap.get("name")); //联系人 - map2.put("phone",cusMap.get("phone")); //联系方式 - } + try(ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())){ + for (MaintenanceTask task : taskList) { + //数据获取 + String templateFile = "MaintenanceTaskReport.xlsx"; + InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFile); + FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); + Map map0 = new HashMap<>(); + map0.put("taskName", task.getDeptName()); + String period = baseMapper.findPeriod(); + map0.put("period",period + "度报告"); + map0.put("time", DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日")); + map0.put("taskCode", task.getTaskCode()); + + Map map1 = new HashMap<>(); + map1.put("taskName", task.getDeptName()); + map1.put("address", task.getDeptName()); + map1.put("taskContent", task.getTaskContent()); + + Map map2 = new HashMap<>(); + map2.put("taskName", task.getDeptName()); + map2.put("address", task.getDeptName()); + map2.put("inspectionConclusion", task.getInspectionConclusion()); + map2.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); + + //获取客户联系人、联系电话 + Map cusMap = baseMapper.getDeptContact(task.getDeptId()); + if(CollectionUtils.isNotEmpty(cusMap)){ + map2.put("contact",cusMap.get("name")); //联系人 + map2.put("phone",cusMap.get("phone")); //联系方式 + } - List maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); - List maintenanceOutputDataList = new ArrayList<>(); - List maintenanceOutputDataList1 = new ArrayList<>(); - long no = 0; - long no1 = 0; - for (MaintenanceTaskDetail maintenanceTaskDetail : maintenanceTaskDetailList) { - no++; - MaintenanceOutputData maintenanceOutputData = new MaintenanceOutputData(); - maintenanceOutputData.setNo(no); - maintenanceOutputData.setFloor(maintenanceTaskDetail.getFloorName()); - maintenanceOutputData.setDeptName(maintenanceTaskDetail.getDeptName()); - maintenanceOutputData.setMajorName(maintenanceTaskDetail.getMajorName()); - maintenanceOutputData.setCheckContent(maintenanceTaskDetail.getCheckContent()); - Optional status = Optional.ofNullable(maintenanceTaskDetail.getStatus()); - if (status.isPresent()) { - if (status.get() == 1) { - maintenanceOutputData.setStatus("异常"); + List maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); + List maintenanceOutputDataList = new ArrayList<>(); + List maintenanceOutputDataList1 = new ArrayList<>(); + long no = 0; + long no1 = 0; + for (MaintenanceTaskDetail maintenanceTaskDetail : maintenanceTaskDetailList) { + no++; + MaintenanceOutputData maintenanceOutputData = new MaintenanceOutputData(); + maintenanceOutputData.setNo(no); + maintenanceOutputData.setFloor(maintenanceTaskDetail.getFloorName()); + maintenanceOutputData.setDeptName(maintenanceTaskDetail.getDeptName()); + maintenanceOutputData.setMajorName(maintenanceTaskDetail.getMajorName()); + maintenanceOutputData.setCheckContent(maintenanceTaskDetail.getCheckContent()); + Optional status = Optional.ofNullable(maintenanceTaskDetail.getStatus()); + if (status.isPresent()) { + if (status.get() == 1) { + maintenanceOutputData.setStatus("异常"); + } + if (status.get() == 0) { + maintenanceOutputData.setStatus("正常"); + } } - if (status.get() == 0) { - maintenanceOutputData.setStatus("正常"); + maintenanceOutputData.setRemark(maintenanceTaskDetail.getRemark()); + maintenanceOutputData.setSignature(task.getSignUrl()); + if (StringUtils.isNotBlank(maintenanceTaskDetail.getPicUrl())) { + try { + //获取图片 + URL url = new URL(maintenanceTaskDetail.getPicUrl()); + HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); + httpURLConnection.setRequestMethod("GET"); + httpURLConnection.setDoInput(true); + InputStream inputStream = httpURLConnection.getInputStream(); + BufferedImage image = ImageIO.read(inputStream); + ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); + ImageIO.write(image, "png", arrayOutputStream); + byte[] bytes = arrayOutputStream.toByteArray(); + maintenanceOutputData.setImage1(bytes); + arrayOutputStream.close(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + maintenanceOutputData.setImage1(null); + } + maintenanceOutputDataList.add(maintenanceOutputData); + if(maintenanceTaskDetail.getStatus() == 1){ + no1++; + MaintenanceOutputData maintenanceOutputData1 = BeanUtil.copyProperties(maintenanceOutputData,MaintenanceOutputData.class); + maintenanceOutputData1.setNo(no1); + maintenanceOutputDataList1.add(maintenanceOutputData1); } } - maintenanceOutputData.setRemark(maintenanceTaskDetail.getRemark()); - maintenanceOutputData.setSignature(task.getSignUrl()); - if (StringUtils.isNotBlank(maintenanceTaskDetail.getPicUrl())) { + //获取签字图片 + if (StringUtils.isNotBlank(task.getSignatureUrl())) { try { //获取图片 - URL url = new URL(maintenanceTaskDetail.getPicUrl()); + URL url = new URL(task.getSignatureUrl()); HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); httpURLConnection.setRequestMethod("GET"); httpURLConnection.setDoInput(true); @@ -263,67 +293,42 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9); + map2.put("image", voidWriteCellData); } catch (Exception e) { throw new RuntimeException(e); } } else { - maintenanceOutputData.setImage1(null); - } - maintenanceOutputDataList.add(maintenanceOutputData); - if(maintenanceTaskDetail.getStatus() == 1){ - no1++; - MaintenanceOutputData maintenanceOutputData1 = BeanUtil.copyProperties(maintenanceOutputData,MaintenanceOutputData.class); - maintenanceOutputData1.setNo(no1); - maintenanceOutputDataList1.add(maintenanceOutputData1); + map2.put("image",null); } - } - //获取签字图片 - if (StringUtils.isNotBlank(task.getSignatureUrl())) { - try { - //获取图片 - URL url = new URL(task.getSignatureUrl()); - HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); - httpURLConnection.setRequestMethod("GET"); - httpURLConnection.setDoInput(true); - InputStream inputStream = httpURLConnection.getInputStream(); - BufferedImage image = ImageIO.read(inputStream); - ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); - ImageIO.write(image, "png", arrayOutputStream); - byte[] bytes = arrayOutputStream.toByteArray(); - Double width = Double.valueOf(image.getWidth()); - Double height = Double.valueOf(image.getHeight()); - WriteCellData voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9); - map2.put("image", voidWriteCellData); - } catch (Exception e) { - throw new RuntimeException(e); + //将数据导出到Excel + String fileName = task.getTaskCode() + "巡检报告.xlsx"; + zos.putNextEntry(new ZipEntry(fileName)); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream).withTemplate(fileInputStream).build()) { + WriteSheet writeSheet0 = EasyExcel.writerSheet(0).build(); + excelWriter.fill(map0, writeSheet0); + + WriteSheet writeSheet1 = EasyExcel.writerSheet(1).build(); + excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet1); + excelWriter.fill(map1, writeSheet1); + + WriteSheet writeSheet2 = EasyExcel.writerSheet(2).build(); + excelWriter.fill(maintenanceOutputDataList1, fillConfig, writeSheet2); + + WriteSheet writeSheet3 = EasyExcel.writerSheet(3).build(); + excelWriter.fill(map2, writeSheet3); + + excelWriter.finish(); + byteArrayOutputStream.writeTo(zos); + zos.closeEntry(); + } - } else { - map2.put("image",null); - } - //将数据导出到Excel - ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); - String fileName = task.getTaskCode() + "巡检报告.xlsx"; - zos.putNextEntry(new ZipEntry(fileName)); - try (ExcelWriter excelWriter = EasyExcel.write(zos).withTemplate(fileInputStream).build()) { - WriteSheet writeSheet0 = EasyExcel.writerSheet(0).build(); - excelWriter.fill(map0, writeSheet0); - - WriteSheet writeSheet1 = EasyExcel.writerSheet(1).build(); - excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet1); - excelWriter.fill(map1, writeSheet1); - - WriteSheet writeSheet2 = EasyExcel.writerSheet(2).build(); - excelWriter.fill(maintenanceOutputDataList1, fillConfig, writeSheet2); - - WriteSheet writeSheet3 = EasyExcel.writerSheet(3).build(); - excelWriter.fill(map2, writeSheet3); - - excelWriter.finish(); - zos.flush(); - zos.closeEntry(); } } + } @Override diff --git a/src/main/java/org/springblade/modules/business/service/impl/MaintenanceTaskServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/MaintenanceTaskServiceImpl.java index ac3a8fe..557c175 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/MaintenanceTaskServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/MaintenanceTaskServiceImpl.java @@ -166,7 +166,7 @@ public class MaintenanceTaskServiceImpl extends BaseServiceImpl> list = baseMapper.selectMaintenanceTaskStatus(startTimeBegin,startTimeEnd,deptId); + List> list = baseMapper.selectMaintenanceTaskStatus(startDate,endDate,deptId); Map dxjMap = new HashMap<>(); Map xjzMap = new HashMap<>(); Map dqrMap = new HashMap<>(); diff --git a/src/main/java/org/springblade/modules/business/service/impl/MessageServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/MessageServiceImpl.java index c66f805..7ba1301 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/MessageServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/MessageServiceImpl.java @@ -81,6 +81,7 @@ public class MessageServiceImpl extends BaseServiceImpl messageVO.setMessageType(record.getMessageType()); messageVO.setStatus(record.getIsRead()); messageVO.setCreateTime(record.getCreateTime()); + messageVO.setRequirementCode(record.getRequirementCode()); messageVOList.add(messageVO); } PageVO pageVO = new PageVO(); diff --git a/src/main/java/org/springblade/modules/business/service/impl/WorkOrderServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/WorkOrderServiceImpl.java index f52e0a7..665d94b 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/WorkOrderServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/WorkOrderServiceImpl.java @@ -707,79 +707,87 @@ public class WorkOrderServiceImpl extends BaseServiceImpl workOrderList, HttpServletResponse response) throws IOException { - for (WorkOrder workOrder : workOrderList) { - //数据获取 - String templateFileName = "WorkOrderServiceSheet.xlsx"; - InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFileName); - Map map = new HashMap<>(); - double total = workOrder.getTotalPrice(); - FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); - List workOrderRepairMaterialList = workOrderRepairMaterialService.list(Wrappers.lambdaQuery(WorkOrderRepairMaterial.class).eq(WorkOrderRepairMaterial::getOrderId, workOrder.getId())); - List workOrderFillDataList = new ArrayList<>(); - int no = 0; - for (WorkOrderRepairMaterial workOrderRepairMaterial : workOrderRepairMaterialList) { - WorkOrderFillData workOrderFillData = new WorkOrderFillData(); - workOrderFillData.setNo(++no); - workOrderFillData.setMaterialName(workOrderRepairMaterial.getMaterialName()); - workOrderFillData.setMaterialCount(workOrderRepairMaterial.getMaterialCount()); - workOrderFillData.setMaterialPrice(workOrderRepairMaterial.getMaterialPrice()); - double price = workOrderRepairMaterial.getMaterialPrice() / workOrderRepairMaterial.getMaterialCount(); - workOrderFillData.setPrice(price); - workOrderFillDataList.add(workOrderFillData); - } + try(ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())){ + for (WorkOrder workOrder : workOrderList) { + //数据获取 + String templateFileName = "WorkOrderServiceSheet.xlsx"; + InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFileName); + Map map = new HashMap<>(); + double total = workOrder.getTotalPrice(); + FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); + List workOrderRepairMaterialList = workOrderRepairMaterialService.list(Wrappers.lambdaQuery(WorkOrderRepairMaterial.class).eq(WorkOrderRepairMaterial::getOrderId, workOrder.getId())); + List workOrderFillDataList = new ArrayList<>(); + int no = 0; + for (WorkOrderRepairMaterial workOrderRepairMaterial : workOrderRepairMaterialList) { + WorkOrderFillData workOrderFillData = new WorkOrderFillData(); + workOrderFillData.setNo(++no); + workOrderFillData.setMaterialName(workOrderRepairMaterial.getMaterialName()); + workOrderFillData.setMaterialCount(workOrderRepairMaterial.getMaterialCount()); + workOrderFillData.setMaterialPrice(workOrderRepairMaterial.getMaterialPrice()); + double price = workOrderRepairMaterial.getMaterialPrice() / workOrderRepairMaterial.getMaterialCount(); + workOrderFillData.setPrice(price); + workOrderFillDataList.add(workOrderFillData); + } // ImageExcelData imageExcelData = new ImageExcelData(); // imageExcelData.setUrl(new URL(workOrder.getSignatureUrl())); - //获取签字图片 - Optional signatureUrl = Optional.ofNullable(workOrder.getSignatureUrl()); - if (signatureUrl.isPresent() && StringUtils.isNotBlank(signatureUrl.get())) { - URL url = new URL(signatureUrl.get()); - HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); - httpURLConnection.setRequestMethod("GET"); - httpURLConnection.setDoInput(true); - InputStream inputStream = httpURLConnection.getInputStream(); - BufferedImage image = ImageIO.read(inputStream); - if (image != null) { - System.out.println("图片加载成功"); - } else { - System.out.println("图片加载失败"); - throw new IOException(); + //获取签字图片 + Optional signatureUrl = Optional.ofNullable(workOrder.getSignatureUrl()); + if (signatureUrl.isPresent() && StringUtils.isNotBlank(signatureUrl.get())) { + URL url = new URL(signatureUrl.get()); + HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); + httpURLConnection.setRequestMethod("GET"); + httpURLConnection.setDoInput(true); + InputStream inputStream = httpURLConnection.getInputStream(); + BufferedImage image = ImageIO.read(inputStream); + if (image != null) { + System.out.println("图片加载成功"); + } else { + System.out.println("图片加载失败"); + throw new IOException(); + } + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ImageIO.write(image, "png", byteArrayOutputStream); // 将图片写入输出流 + byte[] imageBytes = byteArrayOutputStream.toByteArray(); + Double width = Double.valueOf(image.getWidth()); + Double height = Double.valueOf(image.getHeight()); + WriteCellData voidWriteCellData = TemplateExcelUtils.imageCells(imageBytes, width, height, 0.6, 1.9); + map.put("image", voidWriteCellData); } - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - ImageIO.write(image, "png", byteArrayOutputStream); // 将图片写入输出流 - byte[] imageBytes = byteArrayOutputStream.toByteArray(); - Double width = Double.valueOf(image.getWidth()); - Double height = Double.valueOf(image.getHeight()); - WriteCellData voidWriteCellData = TemplateExcelUtils.imageCells(imageBytes, width, height, 0.6, 1.9); - map.put("image", voidWriteCellData); - } - User repairPerson = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, workOrder.getRepairPerson())); - User customer = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, workOrder.getInformant())); - map.put("customerName", customer.getRealName()); - map.put("informant", customer.getRealName()); - map.put("informantPhone", customer.getPhone()); - map.put("address", customer.getAddress()); - map.put("faultDescribe", workOrder.getFaultDescribe()); - map.put("faultCause", workOrder.getFaultCause()); - map.put("total", total); - map.put("processMethod", workOrder.getProcessMethod()); - map.put("repairPerson", repairPerson.getRealName()); - map.put("repairPersonPhone", repairPerson.getPhone()); - map.put("laborCost", workOrder.getLaborCost()); - //转换日期格式 - Optional finishTime = Optional.ofNullable(workOrder.getFinishTime()); - if (finishTime.isPresent()) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); - map.put("finishTime", simpleDateFormat.format(finishTime.get())); - } - Optional device = Optional.ofNullable(deviceService.getOne(Wrappers.lambdaQuery(Device.class).eq(Device::getId, workOrder.getDeviceId()))); - if (device.isPresent()) { - Optional limsId = Optional.ofNullable(device.get().getLimsId()); - if (limsId.isPresent()) { - map.put("in", total + workOrder.getLaborCost()); - map.put("out", "--"); - map.put("sel1", "√"); - map.put("sel2", null); - map.put("inTravel", workOrder.getTravelExpense()); + User repairPerson = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, workOrder.getRepairPerson())); + User customer = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, workOrder.getInformant())); + map.put("customerName", customer.getRealName()); + map.put("informant", customer.getRealName()); + map.put("informantPhone", customer.getPhone()); + map.put("address", customer.getAddress()); + map.put("faultDescribe", workOrder.getFaultDescribe()); + map.put("faultCause", workOrder.getFaultCause()); + map.put("total", total); + map.put("processMethod", workOrder.getProcessMethod()); + map.put("repairPerson", repairPerson.getRealName()); + map.put("repairPersonPhone", repairPerson.getPhone()); + map.put("laborCost", workOrder.getLaborCost()); + //转换日期格式 + Optional finishTime = Optional.ofNullable(workOrder.getFinishTime()); + if (finishTime.isPresent()) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); + map.put("finishTime", simpleDateFormat.format(finishTime.get())); + } + Optional device = Optional.ofNullable(deviceService.getOne(Wrappers.lambdaQuery(Device.class).eq(Device::getId, workOrder.getDeviceId()))); + if (device.isPresent()) { + Optional limsId = Optional.ofNullable(device.get().getLimsId()); + if (limsId.isPresent()) { + map.put("in", total + workOrder.getLaborCost()); + map.put("out", "--"); + map.put("sel1", "√"); + map.put("sel2", null); + map.put("inTravel", workOrder.getTravelExpense()); + } else { + map.put("in", "--"); + map.put("out", total + workOrder.getLaborCost()); + map.put("sel2", "√"); + map.put("sel1", null); + map.put("outTravel", workOrder.getTravelExpense()); + } } else { map.put("in", "--"); map.put("out", total + workOrder.getLaborCost()); @@ -787,36 +795,31 @@ public class WorkOrderServiceImpl extends BaseServiceImpl status = Optional.ofNullable(workOrder.getStatus()); - if (status.isPresent()) { - if (status.get() == 202) { - map.put("sel4", "√"); + Optional status = Optional.ofNullable(workOrder.getStatus()); + if (status.isPresent()) { + if (status.get() == 202) { + map.put("sel4", "√"); + } else { + map.put("sel3", "√"); + } } else { - map.put("sel3", "√"); + map.put("sel4", null); + map.put("sel3", null); + } + //写入Excel并导出 + String fileName = workOrder.getRequirementCode() + "运维服务单.xlsx"; + zos.putNextEntry(new ZipEntry(fileName)); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream).withTemplate(fileInputStream).build()) { + WriteSheet writeSheet = EasyExcel.writerSheet().build(); + excelWriter.fill(workOrderFillDataList, fillConfig, writeSheet); + excelWriter.fill(map, writeSheet); + excelWriter.finish(); + byteArrayOutputStream.writeTo(zos); + zos.closeEntry(); } - } else { - map.put("sel4", null); - map.put("sel3", null); - } - //写入Excel并导出 - ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); - String fileName = workOrder.getReportUnitName() + "运维服务单.xlsx"; - zos.putNextEntry(new ZipEntry(fileName)); - try (ExcelWriter excelWriter = EasyExcel.write(zos).withTemplate(fileInputStream).build()) { - WriteSheet writeSheet = EasyExcel.writerSheet().build(); - excelWriter.fill(workOrderFillDataList, fillConfig, writeSheet); - excelWriter.fill(map, writeSheet); - excelWriter.finish(); - zos.flush(); - zos.closeEntry(); } } + } } diff --git a/src/main/java/org/springblade/modules/business/service/impl/supplies/GoodsServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/supplies/GoodsServiceImpl.java index b743b7f..2d44835 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/supplies/GoodsServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/supplies/GoodsServiceImpl.java @@ -3,14 +3,19 @@ package org.springblade.modules.business.service.impl.supplies; import com.aliyun.oss.ServiceException; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.AllArgsConstructor; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.modules.business.pojo.entity.supplies.Goods; import org.springblade.modules.business.excel.supplies.GoodsExcel; import org.springblade.modules.business.mapper.GoodsMapper; +import org.springblade.modules.business.pojo.entity.supplies.GoodsDetail; import org.springblade.modules.business.pojo.entity.supplies.WareHouse; +import org.springblade.modules.business.service.supplies.IGoodsDetailService; import org.springblade.modules.business.service.supplies.IGoodsService; import org.springblade.modules.business.pojo.vo.supplies.GoodsVO; import org.springblade.modules.business.service.supplies.IWareHouseService; @@ -30,6 +35,7 @@ import java.util.List; public class GoodsServiceImpl extends BaseServiceImpl implements IGoodsService { private final IWareHouseService wareHouseService; + private final IGoodsDetailService goodsDetailService; @Override public IPage selectGoodsPage(IPage page, GoodsVO goods) { @@ -48,13 +54,18 @@ public class GoodsServiceImpl extends BaseServiceImpl implem @Override public void importGoods(List data, Boolean isCovered) { - List list = new ArrayList<>(); + List insertList = new ArrayList<>(); + List updateList = new ArrayList<>(); + List insertDetailList = new ArrayList<>(); // 获取仓库数据 List wareHouses = wareHouseService.list(); // 遍历保存 data.forEach(goodsExcel -> { Goods goods = BeanUtil.copyProperties(goodsExcel, Goods.class); if (goods != null) { + if (StringUtils.isEmpty(goods.getInventoryId())) { + throw new ServiceException("物品【" + goods.getName() + "】未填写库存ID,请修改后再上传!"); + } // 查询符合仓库名称的数据,没有则抛异常 List houseList = wareHouses.stream().filter(wareHouse -> wareHouse.getName().equals(goods.getWarehouseName())).toList(); if (CollectionUtil.isEmpty(houseList)) { @@ -63,14 +74,33 @@ public class GoodsServiceImpl extends BaseServiceImpl implem goods.setWarehouseId(houseList.get(0).getId()); // 是否已停产 goods.setDeactivate("是".equals(goodsExcel.getDeactivate()) ? 1 : 0); - list.add(goods); + //根据inventoryId查询是否已存在 + Goods oldGoods = baseMapper.selectOne(Wrappers.lambdaQuery(Goods.class).eq(Goods::getInventoryId,goods.getInventoryId()).eq(BaseEntity::getIsDeleted,0)); + if(oldGoods != null){ + goods.setId(oldGoods.getId()); + goods.setNum(goods.getNum() + oldGoods.getNum()); + goods.setAllEnterNum(goods.getNum() + oldGoods.getAllEnterNum()); + updateList.add(goods); + }else{ + goods.setAllEnterNum(goods.getNum()); + insertList.add(goods); + } + GoodsDetail goodsDetail = BeanUtil.copyProperties(goods,GoodsDetail.class); + goodsDetail.setId(null); + goodsDetail.setEnterNum(goods.getNum()); + insertDetailList.add(goodsDetail); } }); - if (isCovered) { - this.saveOrUpdateBatch(list); - } else { - this.saveBatch(list); + if(CollectionUtil.isNotEmpty(updateList)){ + this.updateBatchById(updateList); + } + if(CollectionUtil.isNotEmpty(insertList)){ + this.saveBatch(insertList); } + if(CollectionUtil.isNotEmpty(insertDetailList)){ + goodsDetailService.saveBatch(insertDetailList); + } + } } diff --git a/src/main/java/org/springblade/modules/business/service/impl/supplies/InOrderServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/supplies/InOrderServiceImpl.java index 3ae65b0..fc5c832 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/supplies/InOrderServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/supplies/InOrderServiceImpl.java @@ -79,7 +79,7 @@ public class InOrderServiceImpl extends BaseServiceImpl if (goods.getId().equals(inOrderDetail.getGoodsId())) { goods.setNum(goods.getNum() + inOrderDetail.getNum()); GoodsDetail goodsDetail = BeanUtil.copyProperties(goods,GoodsDetail.class); - goodsDetail.setInventoryId(null); + goodsDetail.setId(null); goodsDetail.setEnterNum(inOrderDetail.getNum()); goodsDetailList.add(goodsDetail); break; diff --git a/src/main/java/org/springblade/modules/system/controller/UserController.java b/src/main/java/org/springblade/modules/system/controller/UserController.java index d49c279..ba659ba 100644 --- a/src/main/java/org/springblade/modules/system/controller/UserController.java +++ b/src/main/java/org/springblade/modules/system/controller/UserController.java @@ -358,7 +358,17 @@ public class UserController { @Operation(summary = "获取维修人员", description = "获取维修人员") public R> repairPersons(boolean isRepair) { BladeUser user = AuthUtil.getUser(); - List users = userService.list(Wrappers.lambdaQuery(User.class).eq(User::getRoleId, "1839552581620793346").eq(User::getDeptId,user.getDeptId())); + List users = new ArrayList<>(); + if (!user.getRoleName().contains("administrator") && !user.getRoleName().contains("admin")) { + if(user.getRoleName().equals("客服") || user.getRoleName().equals("维修负责人") || user.getRoleName().equals("维修人员")){ + users = userService.list(Wrappers.lambdaQuery(User.class).eq(User::getRoleId, "1839552581620793346").eq(User::getDeptId,user.getDeptId())); + }else{ + users = userService.list(Wrappers.lambdaQuery(User.class).eq(User::getRoleId, "1839552581620793346").eq(User::getParentDeptId,user.getDeptId())); + } + }else{ + users = userService.list(Wrappers.lambdaQuery(User.class).eq(User::getRoleId, "1839552581620793346")); + } + return R.data(users); }