diff --git a/api-admin/src/main/java/com/glxp/api/admin/controller/inventory/DeviceMAOrderController.java b/api-admin/src/main/java/com/glxp/api/admin/controller/inventory/DeviceMAOrderController.java index a1e0d8be..1c9f13ff 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/controller/inventory/DeviceMAOrderController.java +++ b/api-admin/src/main/java/com/glxp/api/admin/controller/inventory/DeviceMAOrderController.java @@ -1,12 +1,20 @@ package com.glxp.api.admin.controller.inventory; import com.github.pagehelper.PageInfo; +import com.glxp.api.admin.annotation.AuthRuleAnnotation; +import com.glxp.api.admin.entity.info.SystemPDFModuleEntity; +import com.glxp.api.admin.entity.info.SystemPDFTemplateEntity; import com.glxp.api.admin.entity.inventory.DeviceMAOrderEntity; +import com.glxp.api.admin.req.info.SystemPDFModuleRequest; import com.glxp.api.admin.req.inventory.AddDeviceMAOrderRequest; import com.glxp.api.admin.req.inventory.FilterDeviceMAOrderRequest; +import com.glxp.api.admin.req.itextpdf.InspectionPDFTemplateRequest; import com.glxp.api.admin.res.PageSimpleResponse; import com.glxp.api.admin.res.inventory.DeviceMAOrderResponse; +import com.glxp.api.admin.service.info.SystemPDFModuleService; +import com.glxp.api.admin.service.info.SystemPDFTemplateService; import com.glxp.api.admin.service.inventory.DeviceMAOrderService; +import com.glxp.api.admin.util.JasperUtils; import com.glxp.api.common.enums.ResultEnum; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -18,7 +26,10 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; +import java.util.Map; /** * 设备养护记录接口 @@ -29,6 +40,11 @@ public class DeviceMAOrderController { @Resource private DeviceMAOrderService deviceMAOrderService; + @Resource + private SystemPDFTemplateService systemPDFTemplateService; + @Resource + private SystemPDFModuleService systemPDFModuleService; + /** * 查询设备养护记录列表 @@ -109,5 +125,49 @@ public class DeviceMAOrderController { return deviceMAOrderService.addDeviceMAOrder(addDeviceMAOrderRequest); } + /** + * 校验模板文件 + * + * @param inspectionPDFTemplateRequest + * @return + */ + @AuthRuleAnnotation("") + @PostMapping("/device/MA/order/verifyTemplateFile") + public BaseResponse verifyTemplateFile(@RequestBody InspectionPDFTemplateRequest inspectionPDFTemplateRequest) { + if (null == inspectionPDFTemplateRequest) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "参数不能为空!"); + } + //查询模板文件是否存在 + SystemPDFModuleRequest systemPDFModuleRequest = new SystemPDFModuleRequest(); + systemPDFModuleRequest.setId(inspectionPDFTemplateRequest.getModuleId()); + SystemPDFModuleEntity systemPDFModule = systemPDFModuleService.findSystemPDFModule(systemPDFModuleRequest); + if (null == systemPDFModule) { + return ResultVOUtils.error(ResultEnum.DATA_NOT, "所属模块错误"); + } + + SystemPDFTemplateEntity systemPDFTemplateEntity = systemPDFTemplateService.selectById(String.valueOf(systemPDFModule.getTemplateId())); + if (null == systemPDFTemplateEntity) { + return ResultVOUtils.error(ResultEnum.DATA_NOT, "模板错误"); + } + return ResultVOUtils.success(systemPDFModule.getTemplateId()); + } + + /** + * 打印设备养护记录 + * + * @param filterDeviceMAOrderRequest + * @param request + * @param response + * @throws Exception + */ + @AuthRuleAnnotation("") + @PostMapping("/device/MA/order/pintOrder") + public void printOrder(@RequestBody FilterDeviceMAOrderRequest filterDeviceMAOrderRequest, HttpServletRequest request, HttpServletResponse response) throws Exception { + SystemPDFTemplateEntity systemPDFTemplateEntity = systemPDFTemplateService.selectById(filterDeviceMAOrderRequest.getTemplateId()); + //查询打印数据 + Map data = deviceMAOrderService.getPrintData(filterDeviceMAOrderRequest.getOrderId()); + JasperUtils.jasperReport(request, response, data, systemPDFTemplateEntity.getPath(), "pdf"); + } + } diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoDao.java index d33a2244..66f5f441 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoDao.java @@ -59,5 +59,11 @@ public interface UdiInfoDao { */ void updateUdiInfoByUuid(UdiInfoEntity udiInfoEntity); - + /** + * 根据产品ID查询产品名称 + * + * @param productId + * @return + */ + String selectProductNameByProductId(@Param("productId") String productId); } diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/DeviceMAOrderDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/DeviceMAOrderDao.java index 3e5c9fda..49f476de 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/DeviceMAOrderDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/DeviceMAOrderDao.java @@ -5,6 +5,7 @@ import com.glxp.api.admin.entity.inventory.DeviceMAOrderEntity; import com.glxp.api.admin.req.inventory.FilterDeviceMAOrderRequest; import com.glxp.api.admin.res.inventory.DeviceMAOrderResponse; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -24,4 +25,12 @@ public interface DeviceMAOrderDao { int updateByPrimaryKey(DeviceMAOrderEntity record); List filterList(FilterDeviceMAOrderRequest filterDeviceMAOrderRequest); + + /** + * 根据设备养护记录号查询 + * + * @param orderId + * @return + */ + DeviceMAOrderEntity selectByOrderId(@Param("orderId") String orderId); } \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/api/admin/req/inventory/FilterDeviceMAOrderRequest.java b/api-admin/src/main/java/com/glxp/api/admin/req/inventory/FilterDeviceMAOrderRequest.java index 4860bdde..c241bca2 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/req/inventory/FilterDeviceMAOrderRequest.java +++ b/api-admin/src/main/java/com/glxp/api/admin/req/inventory/FilterDeviceMAOrderRequest.java @@ -31,4 +31,9 @@ public class FilterDeviceMAOrderRequest extends ListPageRequest { */ private String code; + /** + * 打印模板ID + */ + private String templateId; + } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/DeviceMAOrderService.java b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/DeviceMAOrderService.java index 31fc59d5..839b8f34 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/DeviceMAOrderService.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/DeviceMAOrderService.java @@ -7,6 +7,7 @@ import com.glxp.api.admin.res.inventory.DeviceMAOrderResponse; import com.glxp.api.common.res.BaseResponse; import java.util.List; +import java.util.Map; /** * 设备养护记录Service @@ -52,4 +53,12 @@ public interface DeviceMAOrderService { * @return */ BaseResponse addDeviceMAOrder(AddDeviceMAOrderRequest addDeviceMAOrderRequest); + + /** + * 查询设备养护记录打印数据 + * + * @param orderId + * @return + */ + Map getPrintData(String orderId); } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/DeviceMAOrderServiceImpl.java b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/DeviceMAOrderServiceImpl.java index b41b8eb7..9e0227a5 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/DeviceMAOrderServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/DeviceMAOrderServiceImpl.java @@ -3,6 +3,7 @@ package com.glxp.api.admin.service.inventory.impl; import cn.hutool.core.util.StrUtil; import com.github.pagehelper.PageHelper; import com.glxp.api.admin.constant.Constant; +import com.glxp.api.admin.dao.basic.UdiInfoDao; import com.glxp.api.admin.dao.inventory.DeviceCollectOrderDetailDao; import com.glxp.api.admin.dao.inventory.DeviceMAOrderDao; import com.glxp.api.admin.dao.inventory.DeviceMaOrderDetailDao; @@ -26,7 +27,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Slf4j @Service @@ -43,6 +46,8 @@ public class DeviceMAOrderServiceImpl implements DeviceMAOrderService { private DeviceCollectOrderDetailDao deviceCollectOrderDetailDao; @Resource private DeviceMaOrderDetailDao deviceMaOrderDetailDao; + @Resource + private UdiInfoDao udiInfoDao; @Override public List filterList(FilterDeviceMAOrderRequest filterDeviceMAOrderRequest) { @@ -166,4 +171,34 @@ public class DeviceMAOrderServiceImpl implements DeviceMAOrderService { return ResultVOUtils.success(); } + @Override + public Map getPrintData(String orderId) { + DeviceMAOrderEntity deviceMAOrderEntity = deviceMAOrderDao.selectByOrderId(orderId); + List detailList = deviceMaOrderDetailDao.selectByOrderId(orderId); + DeviceMAOrderDetailEntity deviceMAOrderDetailEntity = detailList.get(0); + Map data = new HashMap<>(10); + //养护记录号 + data.put("orderId", orderId); + //设备号 + data.put("code", deviceMAOrderDetailEntity.getCode()); + //设备名称 + String productName = udiInfoDao.selectProductNameByProductId(deviceMAOrderDetailEntity.getProductId()); + data.put("productName", productName); + //批次号 + data.put("batchNo", deviceMAOrderDetailEntity.getBatchNo()); + //养护时间 + data.put("createTime", deviceMAOrderEntity.getCreateTime()); + //养护人 + data.put("createUser", deviceMAOrderEntity.getCreateUser()); + //审核人 + data.put("auditUser", deviceMAOrderEntity.getAuditUser()); + //养护说明 + data.put("remark", deviceMAOrderDetailEntity.getRemark()); + //设备状态 + data.put("deviceStatus", deviceMAOrderDetailEntity.getDeviceStatus() == 0 ? "异常" : "正常"); + //养护状态 + data.put("maintenanceStatus", deviceMAOrderDetailEntity.getMaintenanceStatus() == 0 ? "未养护" : "已养护"); + return data; + } + } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvMAOrderServiceImpl.java b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvMAOrderServiceImpl.java index d6fab7ed..e9cb20bc 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvMAOrderServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvMAOrderServiceImpl.java @@ -80,6 +80,7 @@ public class InvMAOrderServiceImpl implements InvMAOrderService { } //复制新数据 BeanUtil.copyProperties(invMaintenanceOrder, maintenanceOrder, "id", "createTime", "createUser"); + maintenanceOrder.setUpdateTime(com.glxp.api.admin.util.DateUtil.getTime()); invMAOrderDao.updateByPrimaryKey(maintenanceOrder); return ResultVOUtils.success("更新成功"); } diff --git a/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoDao.xml b/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoDao.xml index 20e23f9b..802a1a20 100644 --- a/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoDao.xml @@ -363,4 +363,9 @@ #{item.scbssfbhsxrq},#{item.cpms},#{item.originUuid},#{allowNoBatch},#{allowNoExpire},#{allowNoProduct}) + + \ No newline at end of file diff --git a/api-admin/src/main/resources/mybatis/mapper/inventory/DeviceMAOrderDao.xml b/api-admin/src/main/resources/mybatis/mapper/inventory/DeviceMAOrderDao.xml index 07f25032..1a7c65ab 100644 --- a/api-admin/src/main/resources/mybatis/mapper/inventory/DeviceMAOrderDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/inventory/DeviceMAOrderDao.xml @@ -150,7 +150,14 @@ + + \ No newline at end of file diff --git a/api-admin/src/main/resources/schemas/schema_v2.1.sql b/api-admin/src/main/resources/schemas/schema_v2.1.sql index 7b16d267..ac54b72d 100644 --- a/api-admin/src/main/resources/schemas/schema_v2.1.sql +++ b/api-admin/src/main/resources/schemas/schema_v2.1.sql @@ -83,3 +83,10 @@ drop table if exists auth_platform; -- 删除医院客户和自助平台关联表 drop table if exists io_unit_maintain_platform; + +-- 添加设备养护单模板记录 +REPLACE INTO `system_pdf_template` (`id`, `name`, `type`, `module`, `param`, `path`, `rowCount`, `qrcodeCount`, `remark`, `create_time`, `update_time`, `jrxmlPath`) VALUES (17, '设备养护单', 2, 2, '', 'D:/udi/udiwms/udiwmsfile//pdf/template/b914bb90-2dc9-4463-9d07-70b5e44f13bb.jasper', 10, 1, '', '2022-05-12 12:18:21', '2022-06-27 15:20:10', 'D:/udi/udiwms/udiwmsfile//pdf/template/3da2d665-8a31-4fac-84d4-f7b69f5cc846.jrxml'); + +REPLACE INTO system_pdf_module (`id`, `name`, `param`, `fieldExplain`, `remark`, `templateId`, `create_time`, `update_time`, `templateDlUrl`, `templateType`, `remark1`, `remark2`, `remark3` ) +VALUES + ( 7, '单据管理-设备养护记录-单据打印', '', ' orderId 养护记录号\r\n code 设备号\r\n productName 设备名称\r\n batchNo 批次号\r\n createTime 养护时间\r\n createUser 养护人\r\n auditUser 审核人\r\n remark 养护说明\r\n deviceStatus 设备状态\r\n maintenanceStatus 养护状态\r\n remark1 备注字段1\r\n remark2 备注字段2\r\n remark3 备注字段3', NULL, 17, '2022-04-08 14:05:07', '2022-04-08 14:05:10', 'D://1s/udiwms/pdftemplate/stock_order_demo.jrxml', 2, NULL, NULL, NULL );