From ac4d1a5962441156ff22a0c87f4eacc083daa9a6 Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期五, 20 六月 2025 11:32:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java | 3 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml | 18 lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java | 4 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml | 4 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java | 50 +- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java | 2 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java | 16 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java | 16 lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/InboundOrderController.java | 12 lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/InboundOrderServiceImpl.java | 71 +++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java | 3 lxzn-module-tms/src/main/java/org/jeecg/modules/tms/utils/QrCodePrinterUtils.java | 130 +++-- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderDetailController.java | 44 ++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java | 174 +++++--- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamInspectionOrderMapper.xml | 42 ++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java | 20 + lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/vo/InspectionVo.java | 110 +++++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamInspectionOrderService.java | 11 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderDetailController.java | 45 ++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml | 4 lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IInboundOrderService.java | 7 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamInspectionOrderController.java | 277 ++++++++++++++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamInspectionOrderMapper.java | 12 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java | 24 + lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml | 7 25 files changed, 946 insertions(+), 160 deletions(-) diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/vo/InspectionVo.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/vo/InspectionVo.java new file mode 100644 index 0000000..02deb86 --- /dev/null +++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/vo/InspectionVo.java @@ -0,0 +1,110 @@ +package org.jeecg.modules.eam.vo; + +import lombok.Data; + +@Data +public class InspectionVo { + + private String seq; + private String operator;//鎿嶄綔 + private String confirmUser;//宸℃煡 + private String inspectionContent; + private String dayTime; + private String inspectionResult; + private String day1; + private String day2; + private String day3; + private String day4; + private String day5; + private String day6; + private String day7; + private String day8; + private String day9; + private String day10; + private String day11; + private String day12; + private String day13; + private String day14; + private String day15; + private String day16; + private String day17; + private String day18; + private String day19; + private String day20; + private String day21; + private String day22; + private String day23; + private String day24; + private String day25; + private String day26; + private String day27; + private String day28; + private String day29; + private String day30; + private String day31; + + private String confirmUser1; + private String confirmUser2; + private String confirmUser3; + private String confirmUser4; + private String confirmUser5; + private String confirmUser6; + private String confirmUser7; + private String confirmUser8; + private String confirmUser9; + private String confirmUser10; + private String confirmUser11; + private String confirmUser12; + private String confirmUser13; + private String confirmUser14; + private String confirmUser15; + private String confirmUser16; + private String confirmUser17; + private String confirmUser18; + private String confirmUser19; + private String confirmUser20; + private String confirmUser21; + private String confirmUser22; + private String confirmUser23; + private String confirmUser24; + private String confirmUser25; + private String confirmUser26; + private String confirmUser27; + private String confirmUser28; + private String confirmUser29; + private String confirmUser30; + private String confirmUser31; + + private String operator1; + private String operator2; + private String operator3; + private String operator4; + private String operator5; + private String operator6; + private String operator7; + private String operator8; + private String operator9; + private String operator10; + private String operator11; + private String operator12; + private String operator13; + private String operator14; + private String operator15; + private String operator16; + private String operator17; + private String operator18; + private String operator19; + private String operator20; + private String operator21; + private String operator22; + private String operator23; + private String operator24; + private String operator25; + private String operator26; + private String operator27; + private String operator28; + private String operator29; + private String operator30; + private String operator31; + +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamInspectionOrderController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamInspectionOrderController.java index ea4d9df..c5a3769 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamInspectionOrderController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamInspectionOrderController.java @@ -24,6 +24,7 @@ import org.jeecg.modules.eam.request.EamInspectionOrderRequest; import org.jeecg.modules.eam.service.IEamInspectionOrderDetailService; import org.jeecg.modules.eam.service.IEamInspectionOrderService; +import org.jeecg.modules.eam.vo.InspectionVo; import org.jeecg.modules.flowable.domain.vo.WorkTaskDataVo; import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; import org.springframework.beans.factory.annotation.Autowired; @@ -32,8 +33,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; /** * @Description: 鐐规宸ュ崟 @@ -328,4 +331,278 @@ return super.importExcel(request, response, EamInspectionOrder.class); } + /** + * 鎶ヨ〃浣跨敤 qsw + * 2025-6-19 + */ + @GetMapping("/findInspectionResult") + public JSONObject findInspectionResult(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize, + @RequestParam Map<String, Object> params) { + + String equipmentId = (String)params.get("equipmentId"); + String inspectionDate = (String)params.get("inspectionDate"); + + List<InspectionVo> inspectionVos = new ArrayList<>(); + List<Map<String, Object>> inspectionStandard = eamInspectionOrderService.findInspectionStandard(equipmentId); + for (Map<String, Object> map : inspectionStandard) { + List<InspectionVo> dayInspectionResult = eamInspectionOrderService.findInspectionResult(equipmentId,(String)map.get("itemDemand"),inspectionDate); + InspectionVo inspectionVo = new InspectionVo(); + inspectionVo.setInspectionContent((String)map.get("itemDemand")); + Object seq = map.get("seq"); + inspectionVo.setSeq(seq.toString()); + for (InspectionVo vo : dayInspectionResult) { + if("1".equals(vo.getDayTime())){ + inspectionVo.setDay1(vo.getInspectionResult()); + continue; + }else if("2".equals(vo.getDayTime())){ + inspectionVo.setDay2(vo.getInspectionResult()); + continue; + }else if("3".equals(vo.getDayTime())){ + inspectionVo.setDay3(vo.getInspectionResult()); + continue; + }else if("4".equals(vo.getDayTime())){ + inspectionVo.setDay4(vo.getInspectionResult()); + continue; + }else if("5".equals(vo.getDayTime())){ + inspectionVo.setDay5(vo.getInspectionResult()); + continue; + }else if("6".equals(vo.getDayTime())){ + inspectionVo.setDay6(vo.getInspectionResult()); + continue; + }else if("7".equals(vo.getDayTime())){ + inspectionVo.setDay7(vo.getInspectionResult()); + continue; + }else if("8".equals(vo.getDayTime())){ + inspectionVo.setDay8(vo.getInspectionResult()); + continue; + }else if("9".equals(vo.getDayTime())){ + inspectionVo.setDay9(vo.getInspectionResult()); + continue; + }else if("10".equals(vo.getDayTime())){ + inspectionVo.setDay10(vo.getInspectionResult()); + continue; + }else if("11".equals(vo.getDayTime())){ + inspectionVo.setDay11(vo.getInspectionResult()); + continue; + }else if("12".equals(vo.getDayTime())){ + inspectionVo.setDay12(vo.getInspectionResult()); + continue; + }else if("13".equals(vo.getDayTime())){ + inspectionVo.setDay13(vo.getInspectionResult()); + continue; + }else if("14".equals(vo.getDayTime())){ + inspectionVo.setDay14(vo.getInspectionResult()); + continue; + }else if("15".equals(vo.getDayTime())){ + inspectionVo.setDay15(vo.getInspectionResult()); + continue; + }else if("16".equals(vo.getDayTime())){ + inspectionVo.setDay16(vo.getInspectionResult()); + continue; + }else if("17".equals(vo.getDayTime())){ + inspectionVo.setDay17(vo.getInspectionResult()); + continue; + }else if("18".equals(vo.getDayTime())){ + inspectionVo.setDay18(vo.getInspectionResult()); + continue; + }else if("19".equals(vo.getDayTime())){ + inspectionVo.setDay19(vo.getInspectionResult()); + continue; + }else if("20".equals(vo.getDayTime())){ + inspectionVo.setDay20(vo.getInspectionResult()); + continue; + }else if("21".equals(vo.getDayTime())){ + inspectionVo.setDay21(vo.getInspectionResult()); + continue; + }else if("22".equals(vo.getDayTime())){ + inspectionVo.setDay22(vo.getInspectionResult()); + continue; + }else if("23".equals(vo.getDayTime())){ + inspectionVo.setDay23(vo.getInspectionResult()); + continue; + }else if("24".equals(vo.getDayTime())){ + inspectionVo.setDay24(vo.getInspectionResult()); + continue; + }else if("25".equals(vo.getDayTime())){ + inspectionVo.setDay25(vo.getInspectionResult()); + continue; + }else if("26".equals(vo.getDayTime())){ + inspectionVo.setDay26(vo.getInspectionResult()); + continue; + }else if("27".equals(vo.getDayTime())){ + inspectionVo.setDay27(vo.getInspectionResult()); + continue; + }else if("28".equals(vo.getDayTime())){ + inspectionVo.setDay28(vo.getInspectionResult()); + continue; + }else if("29".equals(vo.getDayTime())){ + inspectionVo.setDay29(vo.getInspectionResult()); + continue; + }else if("30".equals(vo.getDayTime())){ + inspectionVo.setDay30(vo.getInspectionResult()); + continue; + }else if("31".equals(vo.getDayTime())){ + inspectionVo.setDay31(vo.getInspectionResult()); + continue; + } + } + inspectionVos.add(inspectionVo); + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",inspectionVos); + return jsonObject; + } + + /** + * 鎶ヨ〃浣跨敤 qsw + * 2025-6-19 + */ + @GetMapping("/findInspectionUser") + public JSONObject findInspectionUser(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize, + @RequestParam Map<String, Object> params) { + + String equipmentId = (String)params.get("equipmentId"); + String inspectionDate = (String)params.get("inspectionDate"); + + List<InspectionVo> inspectionVos = new ArrayList<>(); + List<InspectionVo> inspectionUser = eamInspectionOrderService.findInspectionUser(equipmentId,inspectionDate); + InspectionVo inspectionVo = new InspectionVo(); + for (InspectionVo vo : inspectionUser) { + if("1".equals(vo.getDayTime())){ + inspectionVo.setOperator1(vo.getOperator()); + inspectionVo.setConfirmUser1(vo.getConfirmUser()); + continue; + }else if("2".equals(vo.getDayTime())){ + inspectionVo.setOperator2(vo.getOperator()); + inspectionVo.setConfirmUser2(vo.getConfirmUser()); + continue; + }else if("3".equals(vo.getDayTime())){ + inspectionVo.setOperator3(vo.getOperator()); + inspectionVo.setConfirmUser3(vo.getConfirmUser()); + continue; + }else if("4".equals(vo.getDayTime())){ + inspectionVo.setOperator4(vo.getOperator()); + inspectionVo.setConfirmUser4(vo.getConfirmUser()); + continue; + }else if("5".equals(vo.getDayTime())){ + inspectionVo.setOperator5(vo.getOperator()); + inspectionVo.setConfirmUser5(vo.getConfirmUser()); + continue; + }else if("6".equals(vo.getDayTime())){ + inspectionVo.setOperator6(vo.getOperator()); + inspectionVo.setConfirmUser6(vo.getConfirmUser()); + continue; + }else if("7".equals(vo.getDayTime())){ + inspectionVo.setOperator7(vo.getOperator()); + inspectionVo.setConfirmUser7(vo.getConfirmUser()); + continue; + }else if("8".equals(vo.getDayTime())){ + inspectionVo.setOperator8(vo.getOperator()); + inspectionVo.setConfirmUser8(vo.getConfirmUser()); + continue; + }else if("9".equals(vo.getDayTime())){ + inspectionVo.setOperator9(vo.getOperator()); + inspectionVo.setConfirmUser9(vo.getConfirmUser()); + continue; + }else if("10".equals(vo.getDayTime())){ + inspectionVo.setOperator10(vo.getOperator()); + inspectionVo.setConfirmUser10(vo.getConfirmUser()); + continue; + }else if("11".equals(vo.getDayTime())){ + inspectionVo.setOperator11(vo.getOperator()); + inspectionVo.setConfirmUser11(vo.getConfirmUser()); + continue; + }else if("12".equals(vo.getDayTime())){ + inspectionVo.setOperator12(vo.getOperator()); + inspectionVo.setConfirmUser12(vo.getConfirmUser()); + continue; + }else if("13".equals(vo.getDayTime())){ + inspectionVo.setOperator13(vo.getOperator()); + inspectionVo.setConfirmUser13(vo.getConfirmUser()); + continue; + }else if("14".equals(vo.getDayTime())){ + inspectionVo.setOperator14(vo.getOperator()); + inspectionVo.setConfirmUser14(vo.getConfirmUser()); + continue; + }else if("15".equals(vo.getDayTime())){ + inspectionVo.setOperator15(vo.getOperator()); + inspectionVo.setConfirmUser15(vo.getConfirmUser()); + continue; + }else if("16".equals(vo.getDayTime())){ + inspectionVo.setOperator16(vo.getOperator()); + inspectionVo.setConfirmUser16(vo.getConfirmUser()); + continue; + }else if("17".equals(vo.getDayTime())){ + inspectionVo.setOperator17(vo.getOperator()); + inspectionVo.setConfirmUser17(vo.getConfirmUser()); + continue; + }else if("18".equals(vo.getDayTime())){ + inspectionVo.setOperator18(vo.getOperator()); + inspectionVo.setConfirmUser18(vo.getConfirmUser()); + continue; + }else if("19".equals(vo.getDayTime())){ + inspectionVo.setOperator19(vo.getOperator()); + inspectionVo.setConfirmUser19(vo.getConfirmUser()); + continue; + }else if("20".equals(vo.getDayTime())){ + inspectionVo.setOperator20(vo.getOperator()); + inspectionVo.setConfirmUser20(vo.getConfirmUser()); + continue; + }else if("21".equals(vo.getDayTime())){ + inspectionVo.setOperator21(vo.getOperator()); + inspectionVo.setConfirmUser21(vo.getConfirmUser()); + continue; + }else if("22".equals(vo.getDayTime())){ + inspectionVo.setOperator22(vo.getOperator()); + inspectionVo.setConfirmUser22(vo.getConfirmUser()); + continue; + }else if("23".equals(vo.getDayTime())){ + inspectionVo.setOperator23(vo.getOperator()); + inspectionVo.setConfirmUser23(vo.getConfirmUser()); + continue; + }else if("24".equals(vo.getDayTime())){ + inspectionVo.setOperator24(vo.getOperator()); + inspectionVo.setConfirmUser24(vo.getConfirmUser()); + continue; + }else if("25".equals(vo.getDayTime())){ + inspectionVo.setOperator25(vo.getOperator()); + inspectionVo.setConfirmUser25(vo.getConfirmUser()); + continue; + }else if("26".equals(vo.getDayTime())){ + inspectionVo.setOperator26(vo.getOperator()); + inspectionVo.setConfirmUser26(vo.getConfirmUser()); + continue; + }else if("27".equals(vo.getDayTime())){ + inspectionVo.setOperator27(vo.getOperator()); + inspectionVo.setConfirmUser27(vo.getConfirmUser()); + continue; + }else if("28".equals(vo.getDayTime())){ + inspectionVo.setOperator28(vo.getOperator()); + inspectionVo.setConfirmUser28(vo.getConfirmUser()); + continue; + }else if("29".equals(vo.getDayTime())){ + inspectionVo.setOperator29(vo.getOperator()); + inspectionVo.setConfirmUser29(vo.getConfirmUser()); + continue; + }else if("30".equals(vo.getDayTime())){ + inspectionVo.setOperator30(vo.getOperator()); + inspectionVo.setConfirmUser30(vo.getConfirmUser()); + continue; + }else if("31".equals(vo.getDayTime())){ + inspectionVo.setOperator31(vo.getOperator()); + inspectionVo.setConfirmUser31(vo.getConfirmUser()); + continue; + } + } + inspectionVos.add(inspectionVo); +// } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",inspectionVos); + return jsonObject; + } + + + } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderDetailController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderDetailController.java index 14e4263..cd4f85d 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderDetailController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderDetailController.java @@ -1,7 +1,9 @@ package org.jeecg.modules.eam.controller; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -10,13 +12,16 @@ import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.modules.eam.entity.EamSecondMaintenanceOrderDetail; import org.jeecg.modules.eam.service.IEamSecondMaintenanceOrderDetailService; +import org.jeecg.modules.eam.vo.InspectionVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @Description: 璁惧浜岀骇淇濆吇鏄庣粏 @@ -68,4 +73,44 @@ List<EamSecondMaintenanceOrderDetail> list = eamSecondMaintenanceOrderDetailService.list(queryWrapper); return Result.OK(list); } + + /** + * 鎶ヨ〃浣跨敤 qsw + * 2025-6-19 + */ + @GetMapping("/findExceptionDescriptionAll") + public JSONObject findInspectionUser(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize, + @RequestParam Map<String, Object> params) { + + String orderId = (String)params.get("id"); + + List<EamSecondMaintenanceOrderDetail> details = new ArrayList<>(); + List<EamSecondMaintenanceOrderDetail> list = eamSecondMaintenanceOrderDetailService.lambdaQuery() + .eq(EamSecondMaintenanceOrderDetail::getOrderId, orderId) + .eq(EamSecondMaintenanceOrderDetail::getMaintenanceResult, "2") + .list(); + EamSecondMaintenanceOrderDetail detail = new EamSecondMaintenanceOrderDetail(); + + StringBuilder sb = new StringBuilder(); + int index = 1; + for (EamSecondMaintenanceOrderDetail item : list) { + String value = item.getExceptionDescription(); + if (value != null && !value.isEmpty()) { // 璺宠繃null鍜岀┖瀛楃涓� + sb.append(index).append(". ").append(value).append(System.lineSeparator()); + index++; + } + } + // 绉婚櫎鏈�鍚庝竴涓浣欑殑鎹㈣绗︼紙鍙�夛級 + if (sb.length() > 0) { + sb.setLength(sb.length() - System.lineSeparator().length()); + } + + String s = sb.toString(); + detail.setExceptionDescription(s); + details.add(detail); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",details); + return jsonObject; + } } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderDetailController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderDetailController.java index 94ca430..f436b92 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderDetailController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderDetailController.java @@ -1,5 +1,6 @@ package org.jeecg.modules.eam.controller; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -8,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.modules.eam.entity.EamSecondMaintenanceOrderDetail; import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrderDetail; import org.jeecg.modules.eam.service.IEamThirdMaintenanceOrderDetailService; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +18,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @Description: 璁惧涓夌骇淇濆吇鏄庣粏 @@ -68,4 +72,44 @@ List<EamThirdMaintenanceOrderDetail> list = eamThirdMaintenanceOrderDetailService.list(queryWrapper); return Result.OK(list); } + + /** + * 鎶ヨ〃浣跨敤 qsw + * 2025-6-19 + */ + @GetMapping("/findExceptionDescriptionAll") + public JSONObject findInspectionUser(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize, + @RequestParam Map<String, Object> params) { + + String orderId = (String)params.get("id"); + + List<EamThirdMaintenanceOrderDetail> details = new ArrayList<>(); + List<EamThirdMaintenanceOrderDetail> list = eamThirdMaintenanceOrderDetailService.lambdaQuery() + .eq(EamThirdMaintenanceOrderDetail::getOrderId, orderId) + .eq(EamThirdMaintenanceOrderDetail::getMaintenanceResult, "2") + .list(); + EamThirdMaintenanceOrderDetail detail = new EamThirdMaintenanceOrderDetail(); + + StringBuilder sb = new StringBuilder(); + int index = 1; + for (EamThirdMaintenanceOrderDetail item : list) { + String value = item.getExceptionDescription(); + if (value != null && !value.isEmpty()) { // 璺宠繃null鍜岀┖瀛楃涓� + sb.append(index).append(". ").append(value).append(System.lineSeparator()); + index++; + } + } + // 绉婚櫎鏈�鍚庝竴涓浣欑殑鎹㈣绗︼紙鍙�夛級 + if (sb.length() > 0) { + sb.setLength(sb.length() - System.lineSeparator().length()); + } + + String s = sb.toString(); + detail.setExceptionDescription(s); + details.add(detail); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",details); + return jsonObject; + } } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamInspectionOrderMapper.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamInspectionOrderMapper.java index 0851910..51b179e 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamInspectionOrderMapper.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamInspectionOrderMapper.java @@ -8,6 +8,10 @@ import org.apache.ibatis.annotations.Param; import org.jeecg.modules.eam.entity.EamInspectionOrder; import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; +import org.jeecg.modules.eam.vo.InspectionVo; + +import java.util.List; +import java.util.Map; /** * @Description: 鐐规宸ュ崟 @@ -24,4 +28,12 @@ * @return */ IPage<EamInspectionOrder> queryPageList(Page<EamInspectionOrder> page, @Param(Constants.WRAPPER) QueryWrapper<EamInspectionOrder> queryWrapper); + /** + * 鐐规鎶ヨ〃 new + */ + List<InspectionVo> findInspectionResult(@Param("equipmentId")String equipmentId, @Param("itemDemand")String itemDemand,@Param("yearMonth")String yearMonth); + + List<InspectionVo> findInspectionUser(@Param("equipmentId")String equipmentId,@Param("yearMonth")String yearMonth); + + List<Map<String,Object>> findInspectionStandard(@Param("equipmentId")String equipmentId); } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamInspectionOrderMapper.xml b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamInspectionOrderMapper.xml index b596292..3884cd3 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamInspectionOrderMapper.xml +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamInspectionOrderMapper.xml @@ -9,4 +9,46 @@ on wmo.equipment_id = e.id ${ew.customSqlSegment} </select> + + <select id="findInspectionUser" parameterType="String" resultType="org.jeecg.modules.eam.vo.InspectionVo"> + + SELECT + t1.operator, + t1.confirm_user as confirmUser, + CONVERT(VARCHAR, DATEPART(DAY, t1.inspection_date)) as dayTime + FROM + eam_inspection_order t1 + WHERE t1.del_flag = '0' + AND t1.equipment_id = #{equipmentId} + AND SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t1.inspection_date, 120 ), 1, 7 ) = SUBSTRING(CONVERT(VARCHAR(10),#{yearMonth}, 120 ), 1, 7 ) + </select> + + <select id="findInspectionResult" parameterType="String" resultType="org.jeecg.modules.eam.vo.InspectionVo"> + + SELECT + t1.item_demand as inspectionContent, + CONVERT(VARCHAR, DATEPART(DAY, t2.inspection_date)) as dayTime, + case t1.inspection_result when '1' then '鈭�' when '2' then 'x' else '' end as inspectionResult + FROM + eam_inspection_order_detail t1 + LEFT JOIN eam_inspection_order t2 ON t1.order_id = t2.id + WHERE t1.item_demand = #{itemDemand} + and t2.equipment_id = #{equipmentId} + AND SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t2.inspection_date, 120 ), 1, 7 ) = SUBSTRING(CONVERT(VARCHAR(10),#{yearMonth}, 120 ), 1, 7 ) + </select> + + <select id="findInspectionStandard" parameterType="String" resultType="Map"> + SELECT + ROW_NUMBER() OVER (ORDER BY t1.id) AS seq, + t1.item_demand as itemDemand + FROM + eam_maintenance_standard_detail t1 + LEFT JOIN eam_maintenance_standard t2 ON t1.standard_id = t2.id + WHERE + t2.maintenance_category = 'POINT_INSPECTION' + AND t2.standard_status = 'NORMAL' + and equipment_id =#{equipmentId} + ORDER BY + item_code ASC + </select> </mapper> diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamInspectionOrderService.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamInspectionOrderService.java index 7999fa1..d6dd822 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamInspectionOrderService.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamInspectionOrderService.java @@ -7,8 +7,10 @@ import org.jeecg.modules.eam.entity.EamInspectionOrder; import org.jeecg.modules.eam.request.EamInspectionOrderQuery; import org.jeecg.modules.eam.request.EamInspectionOrderRequest; +import org.jeecg.modules.eam.vo.InspectionVo; import java.util.List; +import java.util.Map; /** * @Description: 鐐规宸ュ崟 @@ -82,4 +84,13 @@ * @return */ List<EamInspectionOrder> selectUnCompleteOrder(String expiredDate); + + /** + * 鐐规鎶ヨ〃 new + */ + List<InspectionVo> findInspectionResult(String equipmentId, String itemDemand,String yearMonth); + + List<InspectionVo> findInspectionUser(String equipmentId,String yearMonth); + + List<Map<String,Object>> findInspectionStandard(String equipmentId); } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java index bf8ebff..8cf5866 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java @@ -35,6 +35,7 @@ import org.jeecg.modules.eam.service.IEamInspectionOrderDetailService; import org.jeecg.modules.eam.service.IEamInspectionOrderService; import org.jeecg.modules.eam.service.IEamReportRepairService; +import org.jeecg.modules.eam.vo.InspectionVo; import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; @@ -540,4 +541,19 @@ Object object = values.get("NextAssignee"); return (List<String>) object; } + + @Override + public List<InspectionVo> findInspectionResult(String equipmentId,String itemDemand,String yearMonth) { + return this.baseMapper.findInspectionResult(equipmentId,itemDemand,yearMonth); + } + + @Override + public List<InspectionVo> findInspectionUser(String equipmentId,String yearMonth) { + return this.baseMapper.findInspectionUser(equipmentId,yearMonth); + } + + @Override + public List<Map<String, Object>> findInspectionStandard(String equipmentId) { + return this.baseMapper.findInspectionStandard(equipmentId); + } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java index 62877b1..fe21267 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java @@ -37,6 +37,22 @@ */ private BigDecimal totalLong = new BigDecimal("0"); /** + * 鏁呴殰鏃堕暱 + */ + private BigDecimal faultLong = new BigDecimal("0"); + /** + * 鏁呴殰鐜� + */ + private BigDecimal faultRate = new BigDecimal("0"); + /** + * 杩愯鏃堕暱(鍘婚櫎鏁呴殰鏃堕棿) + */ + private BigDecimal removeFaultRunLong = new BigDecimal("0"); + /** + * 鍘婚櫎鏁呴殰鏃堕棿鍒╃敤鐜� + */ + private BigDecimal removeFaultRate = new BigDecimal("0"); + /** * 澶╂暟 */ private BigDecimal dayNum; diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java index c987011..822b2ca 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java @@ -78,6 +78,18 @@ @ApiModelProperty(value = "鎶ヨ鏃堕暱") private Integer errorLong; /** + * 鏁呴殰鏃堕暱 + */ + @Excel(name = "鏁呴殰鏃堕暱", width = 15) + @ApiModelProperty(value = "鏁呴殰鏃堕暱") + private Integer faultLong; + /** + * 鍘婚櫎鏁呴殰鏃堕棿鐨勮繍琛屾椂闂� + */ + @Excel(name = "鍘婚櫎鏁呴殰鏃堕棿鐨勮繍琛屾椂闂�", width = 15) + @ApiModelProperty(value = "鍘婚櫎鏁呴殰鏃堕棿鐨勮繍琛屾椂闂�") + private Integer removeFaultRunLong; + /** * 鍒╃敤鐜� */ @Excel(name = "鍒╃敤鐜�", width = 15) @@ -96,6 +108,18 @@ @ApiModelProperty(value = "寮�鏈虹巼") private BigDecimal openRate; /** + * 鏁呴殰鐜� + */ + @Excel(name = "鏁呴殰鐜�", width = 15) + @ApiModelProperty(value = "鏁呴殰鐜�") + private BigDecimal faultRate; + /** + * 鍘婚櫎鏁呴殰鏃堕棿鍒╃敤鐜� + */ + @Excel(name = "鍘婚櫎鏁呴殰鏃堕棿鍒╃敤鐜�", width = 15) + @ApiModelProperty(value = "鍘婚櫎鏁呴殰鏃堕棿鍒╃敤鐜�") + private BigDecimal removeFaultRate; + /** * 鍒涘缓鏃堕棿 */ @Excel(name = "鍒涘缓鏃堕棿", width = 20, format = "yyyy-MM-dd HH:mm:ss") diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java index 456f302..07bbabf 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java @@ -84,7 +84,7 @@ if (StringUtils.isNotBlank(this.parameter)) { date = DateUtils.format(DateUtils.toDate(this.parameter, DateUtils.STRYEARMONTH), DateUtils.STRYEARMONTH); } else { - date = DateUtils.format(DateUtils.getNow(), DateUtils.STRYEARMONTH); + date = DateUtils.format(DateUtils.addMonth(-1, DateUtils.getNow()), DateUtils.STRYEARMONTH); } mdcEquipmentStatisticalInfoMonthService.remove(new LambdaQueryWrapper<MdcEquipmentStatisticalInfoMonth>().eq(MdcEquipmentStatisticalInfoMonth::getTheMonth, date)); mdcEquipmentStatisticalShiftInfoMonthService.remove(new LambdaQueryWrapper<MdcEquipmentStatisticalShiftInfoMonth>().eq(MdcEquipmentStatisticalShiftInfoMonth::getTheMonth, date)); @@ -100,14 +100,20 @@ MdcEquipmentStatisticalInfoMonth mdcEquipmentStatisticalInfoMonth = new MdcEquipmentStatisticalInfoMonth(); mdcEquipmentStatisticalInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId()); mdcEquipmentStatisticalInfoMonth.setTheMonth(date); - mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setProcessLong(mdcEquipmentStatisticalDto.getProcessLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setWaitLong(mdcEquipmentStatisticalDto.getWaitLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("86400").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); - mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); - mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("86400").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); + if (mdcEquipmentStatisticalDto != null) { + mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setProcessLong(mdcEquipmentStatisticalDto.getProcessLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setWaitLong(mdcEquipmentStatisticalDto.getWaitLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); + mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); + mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); + mdcEquipmentStatisticalInfoMonth.setFaultLong(mdcEquipmentStatisticalDto.getFaultLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setFaultRate(mdcEquipmentStatisticalDto.getFaultRate()); + mdcEquipmentStatisticalInfoMonth.setRemoveFaultRate(mdcEquipmentStatisticalDto.getRemoveFaultRate()); + mdcEquipmentStatisticalInfoMonth.setRemoveFaultRunLong(mdcEquipmentStatisticalDto.getRemoveFaultRunLong().intValue()); + } mdcEquipmentStatisticalInfoMonthList.add(mdcEquipmentStatisticalInfoMonth); // step.3 姹囨�荤彮娆″埄鐢ㄧ巼鏁版嵁 MdcEquipmentStatisticalDto mdcEquipmentShiftStatisticalDto = mdcEquipmentStatisticalShiftInfoService.findByEquipmentAndMonth(mdcEquipment.getEquipmentId(), date); @@ -115,15 +121,17 @@ mdcEquipmentShiftInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId()); mdcEquipmentShiftInfoMonth.setTheMonth(date); mdcEquipmentShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_1); - mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong().intValue()); - mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong().intValue()); - mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong().intValue()); - mdcEquipmentShiftInfoMonth.setErrorLong(mdcEquipmentShiftStatisticalDto.getErrorLong().intValue()); - mdcEquipmentShiftInfoMonth.setWaitLong(mdcEquipmentShiftStatisticalDto.getWaitLong().intValue()); - mdcEquipmentShiftInfoMonth.setProcessLong(mdcEquipmentShiftStatisticalDto.getProcessLong().intValue()); - mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); - mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); - mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); + if (mdcEquipmentShiftStatisticalDto != null) { + mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong().intValue()); + mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong().intValue()); + mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong().intValue()); + mdcEquipmentShiftInfoMonth.setErrorLong(mdcEquipmentShiftStatisticalDto.getErrorLong().intValue()); + mdcEquipmentShiftInfoMonth.setWaitLong(mdcEquipmentShiftStatisticalDto.getWaitLong().intValue()); + mdcEquipmentShiftInfoMonth.setProcessLong(mdcEquipmentShiftStatisticalDto.getProcessLong().intValue()); + mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); + mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); + mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); + } mdcEquipmentStatisticalShiftInfoMonthList.add(mdcEquipmentShiftInfoMonth); // step.4 姹囨�诲悇鐝鍒╃敤鐜囨暟鎹� List<MdcEquipmentStatisticalDto> essdList = mdcEquipmentStatisticalShiftInfoService.findShiftByEquipmentAndMonth(mdcEquipment.getEquipmentId(), date); @@ -139,9 +147,9 @@ equipmentStatisticalShiftInfoMonth.setErrorLong(equipmentStatisticalDto.getErrorLong().intValue()); equipmentStatisticalShiftInfoMonth.setWaitLong(equipmentStatisticalDto.getWaitLong().intValue()); equipmentStatisticalShiftInfoMonth.setProcessLong(equipmentStatisticalDto.getProcessLong().intValue()); - equipmentStatisticalShiftInfoMonth.setUtilizationRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); - equipmentStatisticalShiftInfoMonth.setStartRate(equipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); - equipmentStatisticalShiftInfoMonth.setOpenRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getOpenLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); + equipmentStatisticalShiftInfoMonth.setUtilizationRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); + equipmentStatisticalShiftInfoMonth.setStartRate(equipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); + equipmentStatisticalShiftInfoMonth.setOpenRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getOpenLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); mdcEquipmentStatisticalShiftInfoMonthList.add(equipmentStatisticalShiftInfoMonth); } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java index 11cc065..0726a92 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java @@ -16,4 +16,7 @@ public interface MdcEquipmentFaultInfoMapper extends BaseMapper<MdcEquipmentFaultInfo> { List<EquFaultRecord> findFaultRecord(@Param("equipmentIdList") List<String> equipmentIdList, @Param("startTime") String startTime, @Param("endTime") String endTime); + + String getMaxStaticsData(); + } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java index 602ee5c..38c8714 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java @@ -81,4 +81,6 @@ List<MdcEquipmentWaitSectionDto> findWaitList(@Param("date") String date); List<EquFaultRecord> findFaultList(@Param("equipmentId") String equipmentId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); + + MdcEquipmentRunningSection getFirstRecord(); } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml index b5d68c6..d7c9488 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml @@ -195,7 +195,8 @@ SELECT t3.equipment_name, t1.utilization_rate AS utilizationRate, - t2.utilization_rate AS shiftUtilizationRate + t2.utilization_rate AS shiftUtilizationRate, + t1.remove_fault_rate AS amendUtilizationRate FROM mdc_equipment_statistical_info_month t1 LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month AND t2.shift_type = 1 @@ -215,7 +216,8 @@ SELECT t3.team_code AS teamCode, t1.utilization_rate AS utilizationRate, - t2.utilization_rate AS shiftUtilizationRate + t2.utilization_rate AS shiftUtilizationRate, + t1.remove_fault_rate AS amendUtilizationRate FROM mdc_equipment_statistical_info_month t1 LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month AND t2.shift_type = 1 @@ -234,6 +236,7 @@ t1.the_month AS theMonth, AVG ( t1.utilization_rate ) AS utilizationRate, AVG ( t2.utilization_rate ) AS shiftUtilizationRate, + AVG ( t1.remove_fault_rate ) AS amendUtilizationRate, SUM ( t1.process_long ) AS processLong FROM mdc_equipment_statistical_info_month t1 diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml index 35d17f7..3136e97 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml @@ -23,4 +23,8 @@ </foreach> AND t1.report_status != 'ABOLISH' </select> + + <select id="getMaxStaticsData" resultType="java.lang.String"> + SELECT TOP 1 the_date FROM mdc_equipment_fault_info ORDER BY the_date DESC + </select> </mapper> \ No newline at end of file diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml index b2eeea9..964540d 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml @@ -207,5 +207,9 @@ AND t1.report_status != 'ABOLISH' </select> + <select id="getFirstRecord" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection"> + SELECT TOP 1 * FROM mdc_equipment_running_section ORDER BY start_time + </select> + </mapper> \ No newline at end of file diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml index e542769..62ae98e 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml @@ -15,16 +15,20 @@ <select id="findByEquipmentAndMonth" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalDto"> SELECT - SUM(open_long) openLong, - SUM(close_long) closeLong, - SUM(wait_long) waitLong, - SUM(process_long) processLong, - SUM(error_long) errorLong, + SUM ( t1.open_long ) openLong, + SUM ( t1.close_long ) closeLong, + SUM ( t1.wait_long ) waitLong, + SUM ( t1.process_long ) processLong, + SUM ( t1.error_long ) errorLong, + SUM ( t2.fault_long ) faultLong, + AVG ( t2.fault_rate ) faultRate, + SUM ( t2.remove_fault_run_long ) removeFaultRunLong, + AVG ( t2.remove_fault_rate ) removeFaultRate, COUNT(*) dayNum FROM - mdc_equipment_statistical_info + mdc_equipment_statistical_info t1 LEFT JOIN mdc_equipment_fault_info t2 ON t1.equipment_id = t2.equipment_id AND t1.the_date = t2.the_date WHERE - equipment_id = #{equipmentId} AND the_date LIKE CONCAT(#{date}, '%') + t1.equipment_id = #{equipmentId} AND t1.the_date LIKE CONCAT(#{date}, '%') </select> <select id="findByEquIdsAndMonth" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java index 9cbf340..697f76e 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java @@ -90,4 +90,7 @@ List<Integer> getDataList(String equipmentId, Date date); List<MdcEquipmentWaitSectionDto> findWaitList(String date); + + MdcEquipmentRunningSection getFirstRecord(); + } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java index df0f7c6..83fa48f 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java @@ -48,12 +48,31 @@ @Override @Transactional(rollbackFor = {Exception.class}) public void runningAllEquFaultStatistical(String dateTime) { - String validDate = LocalDate.now().minusDays(1).toString().replaceAll("-", ""); + Date initDate = null; + if (StringUtils.isNotBlank(dateTime)) { - validDate = DateUtils.format(DateUtils.toDate(dateTime, DateUtils.STRDATE), DateUtils.STRDATE); + initDate = DateUtils.toDate(dateTime, DateUtils.STRDATE); + } else { + // 鍙栨渶鍚庣殑缁熻鏃堕棿 + String date = this.baseMapper.getMaxStaticsData(); + if (date != null) { + initDate = DateUtils.toDate(date, DateUtils.STRDATE); + } else { + // 鍒濇鍙栧�� 鍙栨渶鏃╂椂闂磋褰� + MdcEquipmentRunningSection equipmentRunningSection = mdcEquipmentRunningSectionService.getFirstRecord(); + if (equipmentRunningSection != null) { + initDate = equipmentRunningSection.getStartTime(); + } + } + } + Date endDate = DateUtils.addDays(DateUtils.getNow(), -1); + List<String> dateList = DateUtils.getDatesStringList2(initDate, endDate); + + if (dateList.isEmpty()) { + return; } try { - this.remove(new LambdaQueryWrapper<MdcEquipmentFaultInfo>().eq(MdcEquipmentFaultInfo::getTheDate, validDate)); + this.remove(new LambdaQueryWrapper<MdcEquipmentFaultInfo>().in(MdcEquipmentFaultInfo::getTheDate, dateList)); } catch (Exception e) { log.error("鍙傛暟鏍煎紡涓嶅", e); } @@ -63,13 +82,6 @@ return; } - Map<String, MdcEquipmentFaultInfo> map = new HashMap<>(); - String finalValidDate = validDate; - equipmentList.forEach(equipment -> { - MdcEquipmentFaultInfo mdcEquipmentFaultInfo = new MdcEquipmentFaultInfo(equipment.getEquipmentid(), finalValidDate); - map.put(equipment.getEquipmentid(), mdcEquipmentFaultInfo); - }); - String planTime = "00:00:00"; MdcSystemParameters mdcSystemParameters = mdcSystemParametersService.getOne(new LambdaQueryWrapper<MdcSystemParameters>().eq(MdcSystemParameters::getCode, "equip_log_statis_time")); if (mdcSystemParameters != null) { @@ -77,56 +89,98 @@ } List<String> equipmentIdList = equipmentList.stream().map(Equipment::getEquipmentid).collect(Collectors.toList()); - String startTime = DateUtils.format(DateUtils.setTimeForDay(DateUtils.toDate(validDate, DateUtils.STRDATE), planTime), DateUtils.STR_DATE_TIME_SMALL); - Date start = DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL); - String endTime = DateUtils.format(DateUtils.addDays(DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL), 1), DateUtils.STR_DATE_TIME_SMALL); - Date end = DateUtils.toDate(endTime, DateUtils.STR_DATE_TIME_SMALL); - //鏌ヨ鏁呴殰璁板綍 - List<EquFaultRecord> equFaultRecordList = this.baseMapper.findFaultRecord(equipmentIdList, startTime, endTime); - if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) { - // 淇暣鏃堕棿 - Map<String, List<EquFaultRecord>> equFaultRecordMap = equFaultRecordList.stream().collect(Collectors.groupingBy(EquFaultRecord::getEquipmentId)); - equFaultRecordMap.forEach((key, value) -> { - if (map.containsKey(key)) { - MdcEquipmentFaultInfo equFaultRecords = map.get(key); - long faultLong = calculateTotalFaultDuration(value, start, end); - equFaultRecords.setFaultLong((int) faultLong); - if (faultLong != 0) { - equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("86400"), 2, RoundingMode.HALF_UP)); - } - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂� - // step.1 鏌ヨ鍔犲伐鏃堕棿 - List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.selectRunningData(key, start, end); - if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { - // 鏃堕棿淇 - if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { - mdcEquipmentRunningSections.get(0).setStartTime(start); - } - if (mdcEquipmentRunningSections.size() > 1) { - if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); - } - } else { - if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(0).setEndTime(end); - } - } - // step.2 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂� - long processingTime = calculateProcessingTimeWithoutFaults(mdcEquipmentRunningSections, value, start, end); - equFaultRecords.setRemoveFaultRunLong((int) processingTime); + for (String validDate : dateList) { + Map<String, MdcEquipmentFaultInfo> map = new HashMap<>(); + String finalValidDate = validDate; + equipmentList.forEach(equipment -> { + MdcEquipmentFaultInfo mdcEquipmentFaultInfo = new MdcEquipmentFaultInfo(equipment.getEquipmentid(), finalValidDate); + map.put(equipment.getEquipmentid(), mdcEquipmentFaultInfo); + }); + + String startTime = DateUtils.format(DateUtils.setTimeForDay(DateUtils.toDate(validDate, DateUtils.STRDATE), planTime), DateUtils.STR_DATE_TIME_SMALL); + Date start = DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL); + String endTime = DateUtils.format(DateUtils.addDays(DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL), 1), DateUtils.STR_DATE_TIME_SMALL); + Date end = DateUtils.toDate(endTime, DateUtils.STR_DATE_TIME_SMALL); + //鏌ヨ鏁呴殰璁板綍 + List<EquFaultRecord> equFaultRecordList = this.baseMapper.findFaultRecord(equipmentIdList, startTime, endTime); + if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) { + // 淇暣鏃堕棿 + Map<String, List<EquFaultRecord>> equFaultRecordMap = equFaultRecordList.stream().collect(Collectors.groupingBy(EquFaultRecord::getEquipmentId)); + map.forEach((key, value1) -> { + MdcEquipmentFaultInfo equFaultRecords = value1; + if (equFaultRecordMap.containsKey(key)) { + List<EquFaultRecord> value = equFaultRecordMap.get(key); + long faultLong = calculateTotalFaultDuration(value, start, end); + equFaultRecords.setFaultLong((int) faultLong); if (faultLong != 0) { - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 - BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("86400").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP); - equFaultRecords.setRemoveFaultRate(removeFaultRate); + equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); + } + // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂� + // step.1 鏌ヨ鍔犲伐鏃堕棿 + List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); + if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { + // 鏃堕棿淇 + if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { + mdcEquipmentRunningSections.get(0).setStartTime(start); + } + if (mdcEquipmentRunningSections.size() > 1) { + if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { + mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); + } + } else { + if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { + mdcEquipmentRunningSections.get(0).setEndTime(end); + } + } + List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); + if (!collect.isEmpty()) { + // step.2 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂� + long processingTime = calculateProcessingTimeWithoutFaults(collect, value, start, end); + equFaultRecords.setRemoveFaultRunLong((int) processingTime); + if (faultLong != 0 && faultLong != 86400) { + // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 + BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("864").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP); + equFaultRecords.setRemoveFaultRate(removeFaultRate); + } + } + } + } else { + List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); + if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { + // 鏃堕棿淇 + if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { + mdcEquipmentRunningSections.get(0).setStartTime(start); + } + if (mdcEquipmentRunningSections.size() > 1) { + if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { + mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); + } + } else { + if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { + mdcEquipmentRunningSections.get(0).setEndTime(end); + } + } + List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); + + if (!collect.isEmpty()) { + long totalProcessingTime = 0; + for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) { + totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime())); + } + equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime); + // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 + BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP); + equFaultRecords.setRemoveFaultRate(removeFaultRate); + } } } map.put(key, equFaultRecords); - } - }); - } - if (!map.isEmpty()) { - this.saveBatch(new ArrayList<>(map.values())); + }); + } + if (!map.isEmpty()) { + this.saveBatch(new ArrayList<>(map.values())); + } } } @@ -215,13 +269,9 @@ LocalDateTime start = DateUtils.convertToLocalDateTime(startTime); LocalDateTime end = DateUtils.convertToLocalDateTime(endTime); - // 灏嗘晠闅滆褰曡浆鎹负鏃堕棿鍖洪棿骞跺悎骞堕噸鍙犻儴鍒� -// List<TimeInterval> faultIntervals = faultRecords.stream() -// .map(record -> new TimeInterval( -// convertToLocalDateTime(record.getStartTime()), -// convertToLocalDateTime(record.getEndTime()))) -// .collect(Collectors.toList()); - List<TimeInterval> mergedFaultIntervals = mergeIntervals(faultRecords); + // 淇璁板綍鏃堕棿 + List<EquFaultRecord> correctedRecords = correctRecordTimes(faultRecords, start, end); + List<TimeInterval> mergedFaultIntervals = mergeIntervals(correctedRecords); long totalProcessingTime = 0; diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java index 158aca7..5db88df 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java @@ -841,14 +841,22 @@ return this.baseMapper.findWaitList(date); } + @Override + public MdcEquipmentRunningSection getFirstRecord() { + return this.baseMapper.getFirstRecord(); + } + private Map<String, List<MdcEquipmentRunningSectionDto>> logCharts(MdcEquipmentRunningSectionVo equipmentRunningSectionVo, String date) { Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>(); List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>(); List<MdcEquipmentRunningSectionDto> waring = new ArrayList<>(); + List<MdcEquipmentRunningSectionDto> fault = new ArrayList<>(); //杩愯 List<MdcEquipmentRunningSection> running = loadEquipmentRunningTrace(equipmentRunningSectionVo.getEquipmentId(), date); //鎶ヨ List<MdcEquipmentRunningSection> errs = loadEquipmentErrorTrace(equipmentRunningSectionVo.getEquipmentId(), date); + //鏁呴殰 + List<MdcEquipmentRunningSection> faults = loadEquipmentFaultTrace(equipmentRunningSectionVo.getEquipmentId(), date); if (running != null && !running.isEmpty()) { MdcEquipmentRunningSectionDto dto; @@ -872,8 +880,20 @@ map.put("waring", null); } + if (!faults.isEmpty()) { + MdcEquipmentRunningSectionDto dto; + for (MdcEquipmentRunningSection mdcEquipmentRunningSection : faults) { + dto = new MdcEquipmentRunningSectionDto(); + BeanUtils.copyProperties(mdcEquipmentRunningSection, dto); + fault.add(dto); + } + } else { + map.put("fault", null); + } + map.put("normal", normal); map.put("waring", waring); + map.put("fault", fault); return map; } diff --git a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/InboundOrderController.java b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/InboundOrderController.java index 71e4a00..679a554 100644 --- a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/InboundOrderController.java +++ b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/InboundOrderController.java @@ -252,17 +252,17 @@ @AutoLog(value = "宸ュ叿鍏ュ簱-鏂板鍏ュ簱") @ApiOperation(value = "宸ュ叿鍏ュ簱-鏂板鍏ュ簱", notes = "宸ュ叿鍏ュ簱-鏂板鍏ュ簱") @PostMapping("/addInStorage") - public Result<?> addInStorage(@RequestBody JSONObject jSONObject) { - inboundOrderService.addInStorage(jSONObject); - return Result.OK("鎿嶄綔鎴愬姛"); + public Result<List<Map<String,String>>> addInStorage(@RequestBody JSONObject jSONObject) { + List<Map<String,String>> result = inboundOrderService.addInStorage(jSONObject); + return Result.OK(result); } @AutoLog(value = "宸ュ叿鍏ュ簱-鐢宠鍗曞叆搴�") @ApiOperation(value = "宸ュ叿鍏ュ簱-鐢宠鍗曞叆搴�", notes = "宸ュ叿鍏ュ簱-鐢宠鍗曞叆搴�") @PostMapping("/addApplyInStorage") - public Result<?> addApplyInStorage(@RequestBody JSONObject jSONObject) { - inboundOrderService.addApplyInStorage(jSONObject); - return Result.OK("鎿嶄綔鎴愬姛"); + public Result<List<Map<String,String>>> addApplyInStorage(@RequestBody JSONObject jSONObject) { + List<Map<String,String>> result = inboundOrderService.addApplyInStorage(jSONObject); + return Result.OK(result); } } diff --git a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IInboundOrderService.java b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IInboundOrderService.java index e892396..02b858f 100644 --- a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IInboundOrderService.java +++ b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IInboundOrderService.java @@ -6,6 +6,9 @@ import org.jeecg.modules.tms.entity.dto.InboundOrderFlowDto; import org.jeecg.modules.tms.entity.dto.OutBoundOrderFlowDto; +import java.util.List; +import java.util.Map; + /** * @Description: 鍏ュ簱鐢宠鍗� * @Author: jeecg-boot @@ -18,7 +21,7 @@ void approvalProcess(InboundOrderFlowDto inboundOrderFlowDto); - void addInStorage(JSONObject jSONObject); + List<Map<String,String>> addInStorage(JSONObject jSONObject); - void addApplyInStorage(JSONObject jSONObject); + List<Map<String,String>> addApplyInStorage(JSONObject jSONObject); } diff --git a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/InboundOrderServiceImpl.java b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/InboundOrderServiceImpl.java index ea6a3a7..b9e31ed 100644 --- a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/InboundOrderServiceImpl.java +++ b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/InboundOrderServiceImpl.java @@ -24,6 +24,7 @@ import org.jeecg.modules.tms.entity.vo.InboundDetailVo; import org.jeecg.modules.tms.mapper.InboundOrderMapper; import org.jeecg.modules.tms.service.*; +import org.jeecg.modules.tms.utils.QrCodePrinterUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -216,9 +217,12 @@ } @Override - public void addInStorage(JSONObject jSONObject) { + public List<Map<String,String>> addInStorage(JSONObject jSONObject) { String inStorehouseType = jSONObject.getString("inStorehouseType"); String locationCodeId = jSONObject.getString("locationCodeId"); + //浜岀淮鐮佹墦鍗板垪琛� + List<Map<String,String>> results = new ArrayList<>(); + List<String> contentList = new ArrayList<>(); String classifyId = jSONObject.getString("classifyId"); Date inboundTime = jSONObject.getDate("inboundTime"); //鑾峰彇鍏ュ簱鏄庣粏 @@ -276,6 +280,7 @@ //澧炲姞搴撳瓨鏄庣粏 ToolLedgerDetail toolLedgerDetail = new ToolLedgerDetail(); toolLedgerDetail.setToolCode(inboundDetailVo.getToolCodeId()); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetail.setToolId(inboundDetailVo.getToolCode()+"-"+result); toolLedgerDetail.setQuantity(BigDecimal.ONE); toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE); @@ -284,7 +289,20 @@ //鏇存柊褰撳墠缂栫爜 newBaseTools.setCurrentCode(result); baseToolsService.updateById(newBaseTools); + //鎵撳嵃浜岀淮鐮� + contentList.add(inboundDetailVo.getToolCode()+"-"+result); } + //鎵撳嵃浜岀淮鐮侊紝鏆傛椂娉ㄩ噴锛屽緟鐜板満璋冭瘯鎵撴爣鏈� +// for(String content : contentList){ +// Map<String,String> result = new HashMap<>(); +// result.put("content",content); +// result.put("image", QrCodePrinterUtils.generateBacthQRCode(content, 200, 200)); +// // 鐢熸垚浜岀淮鐮佸浘鐗囷紙Base64锛� +// results.add(result); +// } + Map<String,String> result = new HashMap<>(); + result.put("content","淇濆瓨鎴愬姛"); + results.add(result); //涓嶇鍒版妸 }else { //淇濆瓨鍏ュ簱娴佹按 @@ -302,12 +320,17 @@ ToolLedgerDetail newToolLedgerDetail = new ToolLedgerDetail(); newToolLedgerDetail.setToolCode(inboundDetailVo.getToolCodeId()); newToolLedgerDetail.setQuantity(inboundDetailVo.getInStorageQuantity()); + newToolLedgerDetail.setPositionCode(locationCodeId); newToolLedgerDetail.setStatus("1"); toolLedgerDetailService.save(newToolLedgerDetail); }else { toolLedgerDetail.setQuantity(toolLedgerDetail.getQuantity().add(inboundDetailVo.getInStorageQuantity())); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetailService.updateById(toolLedgerDetail); } + Map<String,String> result = new HashMap<>(); + result.put("content","淇濆瓨鎴愬姛"); + results.add(result); } } //褰掕繕鍏ュ簱 @@ -330,6 +353,7 @@ .eq(ToolLedgerDetail::getToolId,inboundDetailVo.getOnlyCode()).one(); toolLedgerDetail.setQuantity(BigDecimal.ONE); toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetail.setStatus("1"); toolLedgerDetailService.updateById(toolLedgerDetail); //淇濆瓨鍏ュ簱娴佹按 @@ -347,6 +371,7 @@ //澧炲姞搴撳瓨鏄庣粏鍙敤搴撳瓨锛屼慨鏀圭姸鎬� ToolLedgerDetail toolLedgerDetail = toolLedgerDetailService.lambdaQuery().eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId()).one(); toolLedgerDetail.setQuantity(toolLedgerDetail.getQuantity().add(inboundDetailVo.getInStorageQuantity())); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetail.setStatus("1"); toolLedgerDetailService.updateById(toolLedgerDetail); //淇濆瓨鍏ュ簱娴佹按 @@ -361,6 +386,9 @@ } } + Map<String,String> result = new HashMap<>(); + result.put("content","淇濆瓨鎴愬姛"); + results.add(result); }else if("5".equals(inStorehouseType)){ //寰幆鏂板鏄庣粏 for(InboundDetailVo inboundDetailVo : inStoreDetailList) { @@ -380,6 +408,7 @@ .eq(ToolLedgerDetail::getToolId,inboundDetailVo.getOnlyCode()).one(); toolLedgerDetail.setQuantity(BigDecimal.ONE); toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetail.setStatus("1"); toolLedgerDetailService.updateById(toolLedgerDetail); //淇濆瓨鍏ュ簱娴佹按 @@ -397,6 +426,7 @@ //澧炲姞搴撳瓨鏄庣粏鍙敤搴撳瓨锛屼慨鏀圭姸鎬� ToolLedgerDetail toolLedgerDetail = toolLedgerDetailService.lambdaQuery().eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId()).one(); toolLedgerDetail.setQuantity(toolLedgerDetail.getQuantity().add(inboundDetailVo.getInStorageQuantity())); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetail.setStatus("1"); toolLedgerDetailService.updateById(toolLedgerDetail); //淇濆瓨鍏ュ簱娴佹按 @@ -411,13 +441,20 @@ } } + Map<String,String> result = new HashMap<>(); + result.put("content","淇濆瓨鎴愬姛"); + results.add(result); } + return results; } @Override - public void addApplyInStorage(JSONObject jSONObject) { + public List<Map<String,String>> addApplyInStorage(JSONObject jSONObject) { String inStorehouseType = jSONObject.getString("inStorehouseType"); String locationCodeId = jSONObject.getString("locationCodeId"); + //浜岀淮鐮佹墦鍗板垪琛� + List<Map<String,String>> results = new ArrayList<>(); + List<String> contentList = new ArrayList<>(); //鍏ュ簱鐢宠鍗昳d String orderId = jSONObject.getString("orderId"); //鑾峰彇鍏ュ簱鏄庣粏 @@ -478,12 +515,26 @@ toolLedgerDetail.setToolId(inboundDetailVo.getToolCode()+"-"+result); toolLedgerDetail.setQuantity(BigDecimal.ONE); toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetail.setStatus("1"); toolLedgerDetailService.save(toolLedgerDetail); //鏇存柊褰撳墠缂栫爜 newBaseTools.setCurrentCode(result); baseToolsService.updateById(newBaseTools); + //鎵撳嵃浜岀淮鐮� + contentList.add(inboundDetailVo.getToolCode()+"-"+result); } + //鎵撳嵃浜岀淮鐮侊紝鏆傛椂娉ㄩ噴锛屽緟鐜板満楠岃瘉鎵撴爣鏈� +// for(String content : contentList){ +// Map<String,String> result = new HashMap<>(); +// result.put("content",content); +// result.put("image", QrCodePrinterUtils.generateBacthQRCode(content, 200, 200)); +// // 鐢熸垚浜岀淮鐮佸浘鐗囷紙Base64锛� +// results.add(result); +// } + Map<String,String> result = new HashMap<>(); + result.put("content","淇濆瓨鎴愬姛"); + results.add(result); //涓嶇鍒版妸 }else { //淇濆瓨鍏ュ簱娴佹按 @@ -502,12 +553,17 @@ ToolLedgerDetail newToolLedgerDetail = new ToolLedgerDetail(); newToolLedgerDetail.setToolCode(inboundDetailVo.getToolCodeId()); newToolLedgerDetail.setQuantity(inboundDetailVo.getInStorageQuantity()); + newToolLedgerDetail.setPositionCode(locationCodeId); newToolLedgerDetail.setStatus("1"); toolLedgerDetailService.save(newToolLedgerDetail); }else { toolLedgerDetail.setQuantity(toolLedgerDetail.getQuantity().add(inboundDetailVo.getInStorageQuantity())); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetailService.updateById(toolLedgerDetail); } + Map<String,String> result = new HashMap<>(); + result.put("content","淇濆瓨鎴愬姛"); + results.add(result); } //鏇存敼鏄庣粏鍏ュ簱鐘舵�佸強瀹為檯鍏ュ簱鏁伴噺 InboundDetail inboundDetail = inboundDetailService.getById(inboundDetailVo.getId()); @@ -535,6 +591,7 @@ .eq(ToolLedgerDetail::getToolId,inboundDetailVo.getOnlyCode()).one(); toolLedgerDetail.setQuantity(BigDecimal.ONE); toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetail.setStatus("1"); toolLedgerDetailService.updateById(toolLedgerDetail); //淇濆瓨鍏ュ簱娴佹按 @@ -554,6 +611,7 @@ ToolLedgerDetail toolLedgerDetail = toolLedgerDetailService.lambdaQuery().eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId()).one(); toolLedgerDetail.setQuantity(toolLedgerDetail.getQuantity().add(inboundDetailVo.getInStorageQuantity())); toolLedgerDetail.setStatus("1"); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetailService.updateById(toolLedgerDetail); //淇濆瓨鍏ュ簱娴佹按 InStoreDetail inStoreDetail = new InStoreDetail(); @@ -572,6 +630,9 @@ inboundDetail.setInActualCount(inboundDetailVo.getInStorageQuantity()); inboundDetailService.updateById(inboundDetail); } + Map<String,String> result = new HashMap<>(); + result.put("content","淇濆瓨鎴愬姛"); + results.add(result); }else if("5".equals(inStorehouseType)){ //寰幆鏂板鏄庣粏 for(InboundDetailVo inboundDetailVo : inStoreDetailList) { @@ -591,6 +652,7 @@ .eq(ToolLedgerDetail::getToolId,inboundDetailVo.getOnlyCode()).one(); toolLedgerDetail.setQuantity(BigDecimal.ONE); toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetail.setStatus("1"); toolLedgerDetailService.updateById(toolLedgerDetail); //淇濆瓨鍏ュ簱娴佹按 @@ -610,6 +672,7 @@ ToolLedgerDetail toolLedgerDetail = toolLedgerDetailService.lambdaQuery().eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId()).one(); toolLedgerDetail.setQuantity(toolLedgerDetail.getQuantity().add(inboundDetailVo.getInStorageQuantity())); toolLedgerDetail.setStatus("1"); + toolLedgerDetail.setPositionCode(locationCodeId); toolLedgerDetailService.updateById(toolLedgerDetail); //淇濆瓨鍏ュ簱娴佹按 InStoreDetail inStoreDetail = new InStoreDetail(); @@ -628,6 +691,9 @@ inboundDetail.setInActualCount(inboundDetailVo.getInStorageQuantity()); inboundDetailService.updateById(inboundDetail); } + Map<String,String> result = new HashMap<>(); + result.put("content","淇濆瓨鎴愬姛"); + results.add(result); } //鏇存敼鐢宠鍗曞叆搴撶姸鎬� InboundOrder inboundOrder = this.getById(orderId); @@ -639,6 +705,7 @@ inboundOrder.setInStatus("2"); } this.updateById(inboundOrder); + return results; } private LoginUser getCurrentUser() { diff --git a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java index 2ef6f18..2c06432 100644 --- a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java +++ b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java @@ -388,9 +388,9 @@ Map<String, BigDecimal> outBoundRequestMap = outBoundRequestList.stream() .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, OutBoundRequestDto::getOutboundQuantity)); Map<String, BigDecimal> ratedLifeMap = outBoundRequestList.stream() - .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, dto->dto.getRatedLife() != null ? dto.getRatedLife() : null)); + .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, dto->dto.getRatedLife() != null ? dto.getRatedLife() : BigDecimal.ZERO)); Map<String, BigDecimal> useLifeMap = outBoundRequestList.stream() - .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, dto->dto.getUseLife() != null ? dto.getUseLife() : null)); + .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, dto->dto.getUseLife() != null ? dto.getUseLife() : BigDecimal.ZERO)); //澶勭悊搴撳瓨鍙拌处鍙婂彴璐︽槑缁� Map<String, ToolLedger> toolLedgerMap = toolLedgerService.list(new LambdaQueryWrapper<ToolLedger>().in(ToolLedger::getToolId, toolIdList)).stream() .collect(Collectors.toMap(ToolLedger::getToolId, item -> item, (k1, k2) -> k1)); diff --git a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/utils/QrCodePrinterUtils.java b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/utils/QrCodePrinterUtils.java index bde5895..2c92a36 100644 --- a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/utils/QrCodePrinterUtils.java +++ b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/utils/QrCodePrinterUtils.java @@ -1,74 +1,92 @@ package org.jeecg.modules.tms.utils; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.QRCodeWriter; +import liquibase.pro.packaged.S; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + import javax.print.*; import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import java.awt.print.*; import java.awt.image.BufferedImage; -import java.awt.*; +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.util.*; -public class QrCodePrinterUtils implements Printable { +@RestController +@RequestMapping("/tms/qyCode") +@Slf4j +public class QrCodePrinterUtils{ - private final BufferedImage image; + @GetMapping("/generate") + public Result<Map<String, String>> generateQrCode() throws Exception { + String content = "Q201204330002-0001"; + // 鐢熸垚浜岀淮鐮佸浘鐗囷紙Base64锛� + ByteArrayOutputStream os = new ByteArrayOutputStream(); + generateQRCodeImage(content, 200, 200, os); + String base64Img = "data:image/png;base64," + Base64.getEncoder().encodeToString(os.toByteArray()); - public QrCodePrinterUtils(BufferedImage image) { - this.image = image; + // 杩斿洖缁撴灉 + Map<String, String> result = new HashMap<>(); + result.put("image", base64Img); + result.put("content", content); + return Result.OK(result); } - /** - * 鎵撳嵃浜岀淮鐮� - */ - public void print() { - PrinterJob job = PrinterJob.getPrinterJob(); - job.setPrintable(this); - - // 寮瑰嚭鎵撳嵃瀵硅瘽妗嗭紙鍙�夛級 - if (job.printDialog()) { - try { - job.print(); - } catch (PrinterException e) { - System.err.println("鎵撳嵃澶辫触: " + e.getMessage()); - } - } + public static void generateQRCodeImage(String text, int width, int height, OutputStream os) throws Exception { + QRCodeWriter qrCodeWriter = new QRCodeWriter(); + BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height); + MatrixToImageWriter.writeToStream(bitMatrix, "PNG", os); } - /** - * 瀹炵幇 Printable 鎺ュ彛鐨勬墦鍗版柟娉� - */ - @Override - public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) { - if (pageIndex > 0) { - return NO_SUCH_PAGE; - } - - Graphics2D g2d = (Graphics2D) graphics; - g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); - - // 璁$畻灞呬腑鍧愭爣 - double pageWidth = pageFormat.getImageableWidth(); - double pageHeight = pageFormat.getImageableHeight(); - double imgWidth = image.getWidth(); - double imgHeight = image.getHeight(); - - double scale = Math.min(pageWidth / imgWidth, pageHeight / imgHeight); - g2d.scale(scale, scale); - g2d.drawImage(image, 0, 0, null); - - return PAGE_EXISTS; - } - - /** - * 浣跨敤榛樿鎵撳嵃鏈烘墦鍗帮紝涓嶅脊瀵硅瘽妗� - */ - public static void noDialogPrint(){ - BufferedImage qrImage = QrCodeUtils.generateQrCode("Silent Print", 300, 300); - QrCodePrinterUtils printer = new QrCodePrinterUtils(qrImage); - PrinterJob job = PrinterJob.getPrinterJob(); - job.setPrintable(printer); + public static String generateBacthQRCode(String content, int width, int height) { try { - job.print(); - } catch (PrinterException e) { - e.printStackTrace(); + Map<EncodeHintType, Object> hints = new HashMap<>(); + hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); + hints.put(EncodeHintType.MARGIN, 1); + + BitMatrix matrix = new MultiFormatWriter().encode( + content, + BarcodeFormat.QR_CODE, + width, + height, + hints + ); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + MatrixToImageWriter.writeToStream(matrix, "PNG", os); + + return "data:image/png;base64," + + Base64.getEncoder().encodeToString(os.toByteArray()); + } catch (Exception e) { + throw new RuntimeException("鐢熸垚浜岀淮鐮佸け璐�", e); } } + + @GetMapping("/batchGenerate") + public Result<List<Map<String,String>>> generateBatchQrCode(){ + List<Map<String,String>> results = new ArrayList<>(); + List<String> contentList = new ArrayList<>(); + contentList.add("Q201204330002-0001"); + contentList.add("Q201204330002-0002"); + contentList.add("Q201204330002-0003"); + for(String content : contentList){ + Map<String,String> result = new HashMap<>(); + result.put("content",content); + result.put("image",generateBacthQRCode(content, 200, 200)); + // 鐢熸垚浜岀淮鐮佸浘鐗囷紙Base64锛� + results.add(result); + } + return Result.OK(results); + } } -- Gitblit v1.9.3