已修改12个文件
已重命名1个文件
已删除11个文件
已添加4个文件
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.device.pojo.DeviceDocuments; |
| | | import com.ruoyi.device.service.DeviceDocumentsService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | |
| | | /** |
| | | * è®¾å¤æ¡£æ¡ææ¡£ |
| | | * |
| | | * @author zhuo |
| | | * @since 2025-02-28 |
| | | */ |
| | | @RestController |
| | | @Api(tags = "è®¾å¤æ¡£æ¡ææ¡£") |
| | | @RequestMapping("/deviceDocuments") |
| | | public class DeviceDocumentsController { |
| | | |
| | | @Resource |
| | | private DeviceDocumentsService deviceDocumentsService; |
| | | |
| | | |
| | | /** |
| | | * æ°å¢è®¾å¤æ¡£æ¡ |
| | | * @param document |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "æ°å¢è®¾å¤æ¡£æ¡") |
| | | @PostMapping("/addDocument") |
| | | public Result addDocument(DeviceDocuments document) { |
| | | if (document.getDeviceId() == null) { |
| | | throw new RuntimeException("设å¤id为空"); |
| | | } |
| | | deviceDocumentsService.save(document); |
| | | return Result.success(); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢è®¾å¤æ¡£æ¡ä¿¡æ¯ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "æ¥è¯¢è®¾å¤æ¡£æ¡ä¿¡æ¯") |
| | | @GetMapping("/id") |
| | | public Result getDocumentById(Integer id) { |
| | | return Result.success(deviceDocumentsService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹è®¾å¤æ¡£æ¡ |
| | | * @param document |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "ä¿®æ¹è®¾å¤æ¡£æ¡") |
| | | @PostMapping("/updateDocument") |
| | | public Result updateDocument(@RequestBody DeviceDocuments document) { |
| | | return Result.success(deviceDocumentsService.updateById(document)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤è®¾å¤æ¡£æ¡ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "å é¤è®¾å¤æ¡£æ¡") |
| | | @DeleteMapping("/deleteDocumentById") |
| | | public Result deleteDocumentById(Integer id) { |
| | | return Result.success(deviceDocumentsService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢è®¾å¤æ¡£æ¡å表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "æ¥è¯¢è®¾å¤æ¡£æ¡å表") |
| | | @GetMapping("/getAllDocuments") |
| | | public Result getAllDocuments(Integer id) { |
| | | LambdaQueryWrapper<DeviceDocuments> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(DeviceDocuments::getDeviceId, id); |
| | | return Result.success(deviceDocumentsService.list(lambdaQueryWrapper)); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | import com.ruoyi.device.excel.DeviceMaintenanceExport; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.service.DeviceMaintenanceService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.HorizontalAlignment; |
| | | import org.apache.poi.ss.usermodel.VerticalAlignment; |
| | |
| | | * todo: åæ²³æ»¨ |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/device-maintain") |
| | | @Api(tags = "设å¤ç»´æ¤ä¿å
»") |
| | | @RequestMapping("/deviceMaintain") |
| | | public class DeviceMaintenanceController { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private NumberGenerator<DeviceMaintenance> numberGenerator; |
| | | //å¢ |
| | | @PostMapping() |
| | | public Result create(@RequestBody DeviceMaintenance deviceMaintenance){ |
| | | |
| | | /** |
| | | * æ°å¢è®¾å¤ç»´æ¤ä¿å
» |
| | | * @param deviceMaintenance |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "æ°å¢è®¾å¤ç»´æ¤ä¿å
»") |
| | | @PostMapping("/addDeviceMaintenance") |
| | | public Result addDeviceMaintenance(@RequestBody DeviceMaintenance deviceMaintenance){ |
| | | String year = new SimpleDateFormat("yy", Locale.CHINESE).format(new Date()); |
| | | String month = new SimpleDateFormat("MM", Locale.CHINESE).format(new Date()); |
| | | String processNumber = numberGenerator.generateNumberWithPrefix(3, "DG-TC-23FM " + month + "-" + year + month, DeviceMaintenance::getDeviceNumber); |
| | |
| | | return Result.success(deviceMaintenanceService.save(deviceMaintenance)); |
| | | } |
| | | |
| | | //éè¿deviceIdæ¥è¯¢ç»´æ¤æ°æ® |
| | | /** |
| | | * éè¿è®¾å¤idæ¥è¯¢è®¾å¤ç»´æ¤ä¿å
»ä¿¡æ¯ |
| | | * @param deviceId |
| | | * @param page |
| | | * @param deviceNumber |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "éè¿è®¾å¤idæ¥è¯¢è®¾å¤ç»´æ¤ä¿å
»ä¿¡æ¯") |
| | | @GetMapping("/getDeviceMaintenancePage") |
| | | public Result getDeviceMaintenancePage(@RequestParam("deviceId") Integer deviceId, Page page, String deviceNumber){ |
| | | return Result.success(deviceMaintenanceService.getDeviceMaintenancePage(page, deviceId, deviceNumber)); |
| | | } |
| | | |
| | | //å |
| | | @DeleteMapping("/delete/{id}") |
| | | public void deleteDeviceFault(@PathVariable Integer id) { |
| | | /** |
| | | * å é¤è®¾å¤ç»´æ¤ä¿å
» |
| | | * @param id |
| | | */ |
| | | @ApiOperation(value = "æ°å¢è®¾å¤ç»´æ¤ä¿å
»") |
| | | @DeleteMapping("/deleteDeviceMaintenance") |
| | | public void deleteDeviceMaintenance(@PathVariable Integer id) { |
| | | deviceMaintenanceService.removeById(id); |
| | | } |
| | | |
| | | @GetMapping("/deviceMaintenanceExport") |
| | | public Result deviceMaintenanceExport(@RequestParam("deviceId") Integer deviceId, HttpServletResponse response) throws IOException { |
| | | List<DeviceMaintenanceExport> list = deviceMaintenanceService.deviceMaintenanceExport(deviceId); |
| | | response.setHeader("requestType","excel"); |
| | | response.setHeader("Access-Control-Expose-Headers", "requestType"); |
| | | // 设置åå
æ ¼æ ·å¼ |
| | | // ä¿åå°ç¬¬ä¸ä¸ªsheetä¸ |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head(DeviceMaintenanceExport.class) |
| | | .registerWriteHandler(getHorizontalCellStyleStrategy((short) 12)) |
| | | .sheet() |
| | | .doWrite(list); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "设å¤ç»´æ¤è®°å½å¯¼åº") |
| | | @GetMapping("/exportMaintenanceRecord") |
| | |
| | | deviceMaintenanceService.exportMaintenanceRecord(deviceId, response); |
| | | } |
| | | |
| | | /** |
| | | * åå
æ ¼æ ·å¼çç¥ |
| | | */ |
| | | public static HorizontalCellStyleStrategy getHorizontalCellStyleStrategy(Short fontHeightInPoints) { |
| | | // å
容ççç¥ |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | |
| | | // ãæ°´å¹³å±
ä¸éè¦ä½¿ç¨ä»¥ä¸ä¸¤è¡ã |
| | | // 设置æåå·¦å³å±
ä¸ |
| | | contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
| | | // 设置æåä¸ä¸å±
ä¸ |
| | | contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 设置 èªå¨æ¢è¡ |
| | | contentWriteCellStyle.setWrapped(true); |
| | | |
| | | // æ ·å¼çç¥ |
| | | return new HorizontalCellStyleStrategy(null, contentWriteCellStyle); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.device.pojo.DeviceDocuments; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * è®¾å¤æ¡£æ¡ |
| | | */ |
| | | @Mapper |
| | | public interface DeviceDocumentsMapper extends BaseMapper<DeviceDocuments> { |
| | | } |
| | |
| | | */ |
| | | @Mapper |
| | | public interface DeviceMaintenanceMapper extends BaseMapper<DeviceMaintenance> { |
| | | List<DeviceMaintenance> getDeviceMaintenanceParam(); |
| | | |
| | | |
| | | List<DeviceMaintenanceExport> deviceMaintenanceExport(Integer deviceId); |
| | | } |
ÎļþÃû´Ó cnas-device/src/main/java/com/ruoyi/device/pojo/Document.java ÐÞ¸Ä |
| | |
| | | */ |
| | | @Data |
| | | @TableName(value = "device_documents") |
| | | public class Document implements Serializable { |
| | | public class DeviceDocuments implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | |
| | | /** |
| | | * æä¾æ¥æ |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime provideDate; |
| | | |
| | | /** |
| | |
| | | */ |
| | | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime createdAt; |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updatedAt; |
| | | private LocalDateTime updateTime; |
| | | |
| | | private int deviceId; |
| | | @ApiModelProperty("设å¤id") |
| | | private Integer deviceId; |
| | | |
| | | @ApiModelProperty("èµäº§ç¼å·") |
| | | private String number; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.device.pojo.DeviceDocuments; |
| | | |
| | | /** |
| | | * è®¾å¤æ¡£æ¡ |
| | | */ |
| | | public interface DeviceDocumentsService extends IService<DeviceDocuments> { |
| | | } |
| | |
| | | public interface DeviceMaintenanceService extends IService<DeviceMaintenance> { |
| | | IPage<DeviceMaintenance> getDeviceMaintenancePage(Page page, Integer deviceId, String deviceNumber); |
| | | |
| | | List<DeviceMaintenanceExport> deviceMaintenanceExport(Integer deviceId); |
| | | |
| | | /** |
| | | * 导åºWord设å¤ç»´æ¤è®°å½ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.device.mapper.DeviceDocumentsMapper; |
| | | import com.ruoyi.device.pojo.DeviceDocuments; |
| | | import com.ruoyi.device.service.DeviceDocumentsService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * è®¾å¤æ¡£æ¡ |
| | | */ |
| | | @Service |
| | | public class DeviceDocumentsServiceImpl extends ServiceImpl<DeviceDocumentsMapper, DeviceDocuments> implements DeviceDocumentsService { |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<DeviceMaintenanceExport> deviceMaintenanceExport(Integer deviceId) { |
| | | return baseMapper.deviceMaintenanceExport(deviceId); |
| | | } |
| | | |
| | | @Override |
| | | public void exportMaintenanceRecord(Integer deviceId, HttpServletResponse response) { |
| | | // æ¥è¯¢cnas设å¤ç»´ä¿®è®°å½ |
| | | List<DeviceMaintenance> deviceMaintenanceList = baseMapper.selectList(Wrappers.<DeviceMaintenance>lambdaQuery() |
| | |
| | | import com.ruoyi.device.pojo.*; |
| | | import com.ruoyi.device.service.DataConfigService; |
| | | import com.ruoyi.device.service.DeviceService; |
| | | import com.ruoyi.device.service.DocumentService; |
| | | import com.ruoyi.device.service.DeviceDocumentsService; |
| | | import com.ruoyi.device.utils.DataAcquisition; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.mapper.InsSampleMapper; |
| | |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | |
| | | private DataConfigService dataConfigService; |
| | | |
| | | private QrShowServiceImpl qrShowService; |
| | | |
| | | private InsSampleMapper insSampleMapper; |
| | | |
| | | private DocumentService documentService; |
| | | private DeviceDocumentsService documentService; |
| | | |
| | | private DeviceMetricRecordMapper deviceMetricRecordMapper; |
| | | |
| | |
| | | } |
| | | deviceDto.setAuthorizedPersonName(name); |
| | | //æ¥è¯¢è®¾å¤æ ¡åä¿¡æ¯ |
| | | DeviceMetricRecord calibrate = qrShowService.getDeviceMetricRecord(id, "calibrate"); |
| | | DeviceMetricRecord calibrate = getDeviceMetricRecord(id, "calibrate"); |
| | | deviceDto.setCalibrateNo(calibrate.getCertificateSerialNumber()); |
| | | |
| | | // å°äºåç¨æ¥æï¼èªå¨å°ç¶ææ¹ä¸ºåç¨ |
| | |
| | | } |
| | | } |
| | | return deviceDto; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢è®¾å¤æ ¡å/æ ¸æ¥è®°å½ |
| | | * @param deviceId |
| | | * @param type |
| | | * @return |
| | | */ |
| | | public DeviceMetricRecord getDeviceMetricRecord(int deviceId, String type){ |
| | | return Optional.ofNullable( |
| | | deviceMetricRecordMapper.selectOne(Wrappers.<DeviceMetricRecord>lambdaQuery() |
| | | .eq(DeviceMetricRecord::getDeviceId, deviceId) |
| | | .eq(DeviceMetricRecord::getType, type) |
| | | .orderByDesc(DeviceMetricRecord::getCreateTime) |
| | | .last("limit 1"))).orElse(new DeviceMetricRecord()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // 设å¤ä¿¡æ¯ |
| | | Device device = baseMapper.selectById(deviceId); |
| | | // è®¾å¤æ¡£æ¡ |
| | | List<Document> documentList = documentService.list(Wrappers.<Document>lambdaQuery().eq(Document::getDeviceId, deviceId)); |
| | | List<DeviceDocuments> documentList = documentService.list(Wrappers.<DeviceDocuments>lambdaQuery().eq(DeviceDocuments::getDeviceId, deviceId)); |
| | | // è®¾å¤æ ¡å表 |
| | | List<DeviceMetricRecord> deviceMetricRecordList = deviceMetricRecordMapper.selectList(Wrappers.<DeviceMetricRecord>lambdaQuery().eq(DeviceMetricRecord::getDeviceId, deviceId)); |
| | | // 设å¤ç»´ä¿®è¡¨ |
| | |
| | | * @param documentList æ¡£æ¡å表 |
| | | * @param documentExportWordDtoList è¿åç»wordçæ°æ®å表 |
| | | */ |
| | | private static void extracted(List<Document> documentList, List<DocumentExportWordDto> documentExportWordDtoList) { |
| | | private static void extracted(List<DeviceDocuments> documentList, List<DocumentExportWordDto> documentExportWordDtoList) { |
| | | // ç»æ¡£æ¡å åºå· å¹¶ä¸å为左å³ä¸¤ä¸ªå表å¨word䏿¾ç¤º |
| | | for (int i = 0; i < documentList.size(); i++) { |
| | | // å建wordè¡¨æ ¼ä¸ä¸è¡çæ°æ®å¯¹è±¡ |
| | | DocumentExportWordDto documentExportWordDto = new DocumentExportWordDto(); |
| | | // è·åæ¡£æ¡ä¿¡æ¯ |
| | | Document document = documentList.get(i); |
| | | DeviceDocuments document = documentList.get(i); |
| | | // æ ¼å¼åæ¥æ |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | // æ ¹æ®åºå· åå«å å
¥ä¸¤ä¸ªå表 |
| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.device.mapper.DeviceMaintenanceMapper"> |
| | | |
| | | <select id="getDeviceMaintenanceParam" resultType="com.ruoyi.device.pojo.DeviceMaintenance"> |
| | | select id,device_id,device_name, device_number,management_number,content,name |
| | | ,date from device_maintenance |
| | | </select> |
| | | |
| | | |
| | | <select id="deviceMaintenanceExport" resultType="com.ruoyi.device.excel.DeviceMaintenanceExport"> |
| | | select id, device_id, device_name, device_number, management_number, content, date, if(maintenance_type = 1, '计åä¸ç»´æ¤', '使ç¨ååç»´æ¤'), next_date, name, comments |
| | | from device_maintenance dm |
| | | where dm.device_id = #{deviceId} |
| | | </select> |
| | | </mapper> |
| | |
| | | return Result.success(insOrderService.selectSampleAndProductByOrderId(page, sampleProductDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "è´¹ç¨ç»è®¡") |
| | | @GetMapping("/costStatistics") |
| | | public Result<?> costStatistics(Page page, CostStatisticsDto costStatisticsDto){ |
| | | return Result.success(insOrderService.costStatistics(page, costStatisticsDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "è´¹ç¨ç»è®¡è·åæ»ä»·") |
| | | @GetMapping("/costStatistics2") |
| | | public Result<?> costStatistics2(CostStatisticsDto costStatisticsDto){ |
| | | return Result.success(insOrderService.costStatistics2(costStatisticsDto)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "æ ·åç¼ºé·ææ°") |
| | | @GetMapping("/selectSampleDefects") |
| | | public Result selectSampleDefects(Integer size, Integer current, String inspectionItems, String orderNumber) { |
| | | return Result.success(insOrderService.selectSampleDefects(new Page<>(current, size),inspectionItems, orderNumber)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "æ¤é") |
| | | @PostMapping("/updateStatus") |
| | |
| | | Integer state = (Integer) param.get("state"); |
| | | insProductService.checkUpdate(orderId,state); |
| | | return Result.success(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "è´¹ç¨ç»è®¡å¯¼åº") |
| | | @GetMapping("/export") |
| | | public void export(CostStatisticsDto costStatisticsDto,HttpServletResponse response) throws ServletException, IOException { |
| | | insOrderService.export(costStatisticsDto,response); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | IPage<SampleProductDto2> selectSampleAndProductByOrderId(@Param("page") IPage<SampleProductDto2> page, @Param("ew") QueryWrapper<SampleProductDto2> ew, @Param("id") Integer id); |
| | | |
| | | IPage<CostStatisticsDto> selectCostStatistics(@Param("page") IPage<CostStatisticsDto> page, @Param("ew") QueryWrapper<CostStatisticsDto> ew); |
| | | |
| | | List<CostStatisticsDto> selectCostStatistics2(@Param("ew") QueryWrapper<CostStatisticsDto> ew); |
| | | |
| | | List<Map<String, String>> selectDeviceList(@Param("managementNumbers") Set<String> managementNumbers); |
| | | List<SampleDefectsFatherVo> selectSampleDefects(Page page, @Param("inspectionItems") String inspectionItems, @Param("orderNumber") String orderNumber); |
| | | |
| | | Long getCount(@Param("inspectionItems") String inspectionItems, @Param("orderNumber") String orderNumber); |
| | | |
| | | String getStandardMethodCode(@Param("id") Integer id); |
| | | |
| | |
| | | |
| | | IPage<SampleProductDto2> selectSampleAndProductByOrderId(IPage<SampleProductDto2> page, SampleProductDto2 sampleProductDto); |
| | | |
| | | IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto); |
| | | |
| | | Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto); |
| | | |
| | | Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber); |
| | | |
| | | int updateStatus(Integer id); |
| | | |
| | | |
| | | void export(CostStatisticsDto costStatisticsDto,HttpServletResponse response)throws IOException, ServletException; |
| | | |
| | | // è·åifsåºåä¿¡æ¯ |
| | | void getIfsOrder(); |
| | |
| | | @Resource |
| | | private InsProductUserMapper insProductUserMapper; |
| | | @Resource |
| | | private InsUnPassService insUnPassService; |
| | | @Resource |
| | | private AuxiliaryOutputWorkingHoursService auxiliaryOutputWorkingHoursService; |
| | | @Resource |
| | | private AuxiliaryOutputWorkingHoursTemporaryService auxiliaryOutputWorkingHoursTemporaryService; |
| | |
| | | private CustomMapper customMapper; |
| | | @Value("${file.path}") |
| | | private String imgUrl; |
| | | |
| | | @Resource |
| | | private InsOrderFileMapper insOrderFileMapper; |
| | | @Resource |
| | |
| | | * @param orderId |
| | | */ |
| | | private void generateReport(Integer orderId) { |
| | | List<InsUnPass> insUnPasses = new ArrayList<>(); |
| | | /*æ ·åä¸ç项ç®åªè¦æä¸ä¸ªé¡¹ç®ä¸åæ ¼åæ£éªç»æä¸º0,å¦å为1*/ |
| | | //è¿éçinsSamplesæ¯è®¢åä¸çæææ ·åå
æ¬("/") |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)); |
| | |
| | | insSample.setInsResult(1); |
| | | } |
| | | insSampleMapper.updateById(insSample); |
| | | /*夿 ¸éè¿åï¼å°ä¸åæ ¼ç项ç®ä¿¡æ¯æ·»å å°ins_un_pass表ä¸*/ |
| | | for (InsProduct insProduct : insProducts) { |
| | | if (insProduct.getInsResult() == 0) { |
| | | InsUnPass insUnPass = new InsUnPass(); |
| | | insUnPass.setId(null); |
| | | insUnPass.setModel(insSample.getModel()); |
| | | insUnPass.setSample(insSample.getSample()); |
| | | insUnPass.setInspectionItem(insProduct.getInspectionItem()); |
| | | insUnPass.setInspectionItemSubclass(insProduct.getInspectionItemSubclass()); |
| | | insUnPass.setLastValue(insProduct.getLastValue()); |
| | | insUnPass.setEntrustCode(insOrderMapper.selectById(orderId).getEntrustCode()); |
| | | List<Integer> userIds = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery().eq(InsProductUser::getInsProductId, insProduct.getId())).stream().map(InsProductUser::getCreateUser).distinct().collect(Collectors.toList()); |
| | | String name = userMapper.selectBatchIds(userIds).stream().map(User::getName).collect(Collectors.joining(",")); |
| | | insUnPass.setName(name); |
| | | insUnPasses.add(insUnPass); |
| | | } |
| | | } |
| | | } |
| | | insUnPassService.saveBatch(insUnPasses); |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | // æ½æ£åæå§ææ£éª |
| | | if (insOrder.getOrderType().equals(InsOrderTypeConstants.SPOT_CHECK)) { |
| | |
| | | return productDto2IPage; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) { |
| | | String dates = costStatisticsDto.getDates(); |
| | | String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | | costStatisticsDto.setDates(null); |
| | | |
| | | //todo:ä»
çèªå·± |
| | | |
| | | IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); |
| | | List<CostStatisticsDto> collect = dtoIPage.getRecords().stream().map(dto -> { |
| | | Set<String> uniqueTags = new HashSet<>(); |
| | | if (dto.getInspectionItem().contains(",")) { |
| | | for (String s : dto.getInspectionItem().split(",")) { |
| | | uniqueTags.add(s.split("@")[0]); |
| | | } |
| | | } else { |
| | | uniqueTags.add(dto.getInspectionItem().split("@")[0]); |
| | | } |
| | | dto.setInspectionItem(uniqueTags.toString()); |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | | dtoIPage.setRecords(collect); |
| | | return dtoIPage; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | String dates = costStatisticsDto.getDates(); |
| | | String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | | costStatisticsDto.setDates(null); |
| | | List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); |
| | | double totalPrice = costStatisticsDtos.stream() |
| | | .filter(dto -> dto.getPrice() != null) // è¿æ»¤æä»·æ ¼ä¸º null ç对象 |
| | | .mapToDouble(value -> value.getPrice().doubleValue() * value.getNum()) |
| | | .sum(); |
| | | map.put("total", totalPrice); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber) { |
| | | List<SampleDefectsFatherVo> sampleDefectsFatherVos = insOrderMapper.selectSampleDefects(page, inspectionItems, orderNumber); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("records", sampleDefectsFatherVos); |
| | | Long aLong = insOrderMapper.getCount(inspectionItems, orderNumber); |
| | | map.put("total", aLong); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public int updateStatus(Integer id) { |
| | | return insOrderMapper.updateStatus(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void export(CostStatisticsDto costStatisticsDto, HttpServletResponse response) throws IOException { |
| | | //æ¥è¯¢å¯¼åºçè´¹ç¨ç»è®¡æ°æ® |
| | | String dates = costStatisticsDto.getDates(); |
| | | String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | | costStatisticsDto.setDates(null); |
| | | List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); |
| | | costStatisticsDtos = costStatisticsDtos.stream().map(dto -> { |
| | | Set<String> uniqueTags = new HashSet<>(); |
| | | if (dto.getInspectionItem().contains(",")) { |
| | | for (String s : dto.getInspectionItem().split(",")) { |
| | | uniqueTags.add(s.split("@")[0]); |
| | | } |
| | | } else { |
| | | uniqueTags.add(dto.getInspectionItem().split("@")[0]); |
| | | } |
| | | dto.setInspectionItem(uniqueTags.toString()); |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | // è¿éURLEncoder.encodeå¯ä»¥é²æ¢ä¸æä¹±ç å½ç¶åeasyexcel没æå
³ç³» |
| | | String fileName = URLEncoder.encode("æ ·åè´¹ç¨ç»è®¡å¯¼åº", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | Map<String, List<CostStatisticsDto>> groupByCompany = |
| | | costStatisticsDtos.stream().filter(e -> StrUtil.isNotEmpty(e.getCompany())) |
| | | .collect(Collectors.groupingBy(CostStatisticsDto::getCompany)); |
| | | try { |
| | | // æ°å»ºExcelWriter |
| | | // æ°å»ºExcelWriter |
| | | ExcelWriter excelWriter = |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) |
| | | .build(); |
| | | for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) { |
| | | String sheetName = companyDataEntry.getKey(); |
| | | List<CostStatisticsDto> dataList = companyDataEntry.getValue(); |
| | | WriteSheet mainSheet = EasyExcel.writerSheet(sheetName) |
| | | .head(CostStatisticsDto.class) |
| | | .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) |
| | | .build(); |
| | | excelWriter.write(dataList, mainSheet); |
| | | } |
| | | // å
³éæµ |
| | | excelWriter.finish(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("导åºå¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åifsåºåä¿¡æ¯ |
| | |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | <select id="selectCostStatistics" resultType="com.ruoyi.inspect.dto.CostStatisticsDto"> |
| | | select * from ( |
| | | SELECT A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name`, |
| | | COUNT(1) num, |
| | | SUM(A.price) price, |
| | | SUM(A.cost) cost |
| | | FROM |
| | | (SELECT |
| | | i.id, |
| | | i.entrust_code, |
| | | i.create_time, |
| | | isa.sample, |
| | | isa.sample_code, |
| | | isa.model, |
| | | c.price, |
| | | c.cost, |
| | | c.inspection_item, |
| | | i.company, |
| | | u.`name`, |
| | | i.create_user, |
| | | c.ins_sample_id |
| | | FROM |
| | | ins_order i |
| | | LEFT JOIN ins_sample isa ON isa.ins_order_id = i.id |
| | | LEFT JOIN `user` u ON u.id = i.user_id |
| | | left join custom cus on cus.id = u.company |
| | | LEFT JOIN (select SUM(b.price) price, sum(b.man_hour) cost,b.ins_sample_id, |
| | | GROUP_CONCAT(b.inspection_item2 |
| | | SEPARATOR ',') |
| | | inspection_item from (select * , |
| | | GROUP_CONCAT(CONCAT(inspection_item,'@',inspection_item_subclass) SEPARATOR ',')inspection_item2 from ins_product where state = 1 and template_id IS NOT NULL GROUP BY ins_sample_id,man_hour_group) b GROUP |
| | | BY b.ins_sample_id) c ON c.ins_sample_id = isa.id |
| | | where (i.state = 1 or i.state = 3 or i.state = 4) and c.ins_sample_id IS not NULL)A |
| | | GROUP BY |
| | | A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name` |
| | | ) B |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectDeviceList" resultType="java.util.Map"> |
| | | select device_name, |
| | | en_device_name, |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getCount" resultType="long"> |
| | | select count(1) |
| | | from ( |
| | | SELECT io.entrust_code,sam.sample,ip.inspection_item,u.name,b.create_time, sam.id |
| | | from ins_order io |
| | | left JOIN ins_sample sam on io.id=sam.ins_order_id |
| | | LEFT JOIN ins_product ip on ip.ins_sample_id=sam.id |
| | | LEFT JOIN |
| | | (SELECT create_time,create_user,ins_product_id FROM (select * FROM ins_product_user ORDER BY |
| | | ins_product_user.create_time DESC) a GROUP BY a.ins_product_id) b |
| | | on b.ins_product_id=ip.id |
| | | left JOIN `user` u on u.id=b.create_user |
| | | where (ip.ins_result=0 OR ip.state=0) |
| | | <if test="inspectionItems != null and inspectionItems != ''"> |
| | | and inspection_item like concat('%', #{inspectionItems}, '%') |
| | | </if> |
| | | <if test="orderNumber != null and orderNumber != ''"> |
| | | and io.entrust_code like concat('%', #{orderNumber}, '%') |
| | | </if> |
| | | ) temp |
| | | </select> |
| | | |
| | | <select id="getStandardMethodCode" resultType="java.lang.String"> |
| | | select code |
| | | from standard_method |
| | |
| | | where son_laboratory = #{laboratory} |
| | | and ins_sample_id in |
| | | (select id from ins_sample where ins_order_id = #{id})) |
| | | </select> |
| | | |
| | | <select id="selectCostStatistics2" resultType="com.ruoyi.inspect.dto.CostStatisticsDto"> |
| | | select * from ( |
| | | SELECT A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name`, |
| | | production, |
| | | engineering, |
| | | COUNT(1) num, |
| | | SUM(A.price) price, |
| | | SUM(A.cost) cost |
| | | FROM |
| | | (SELECT |
| | | i.id, |
| | | i.entrust_code, |
| | | i.create_time, |
| | | isa.sample, |
| | | isa.sample_code, |
| | | isa.model, |
| | | c.price, |
| | | c.cost, |
| | | c.inspection_item, |
| | | i.company, |
| | | u.`name`, |
| | | i.create_user, |
| | | c.ins_sample_id, |
| | | production, |
| | | engineering |
| | | FROM |
| | | ins_order i |
| | | LEFT JOIN ins_sample isa ON isa.ins_order_id = i.id |
| | | LEFT JOIN `user` u ON u.id = i.user_id |
| | | left join custom cus on cus.id = u.company |
| | | LEFT JOIN (select SUM(b.price) price, sum(b.man_hour) cost,b.ins_sample_id, |
| | | GROUP_CONCAT(b.inspection_item2 |
| | | SEPARATOR ',') |
| | | inspection_item from (select * , |
| | | GROUP_CONCAT(CONCAT(inspection_item,'@',inspection_item_subclass) SEPARATOR ',')inspection_item2 from ins_product where state = 1 and template_id IS NOT NULL GROUP BY ins_sample_id,man_hour_group) b GROUP |
| | | BY b.ins_sample_id) c ON c.ins_sample_id = isa.id |
| | | where (i.state = 1 or i.state = 3 or i.state = 4) and c.ins_sample_id IS not NULL)A |
| | | GROUP BY |
| | | A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name`, |
| | | production, |
| | | engineering |
| | | ORDER BY |
| | | A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name`, |
| | | production, |
| | | engineering) B |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="seldepLimsId" resultType="java.lang.String"> |