diff --git a/aucma-api/src/main/java/com/aucma/api/controller/ElectricalInspectionController.java b/aucma-api/src/main/java/com/aucma/api/controller/ElectricalInspectionController.java new file mode 100644 index 0000000..31b5ac4 --- /dev/null +++ b/aucma-api/src/main/java/com/aucma/api/controller/ElectricalInspectionController.java @@ -0,0 +1,43 @@ +package com.aucma.api.controller; + +import com.aucma.api.domain.dto.SAPPortDto; +import com.aucma.api.domain.dto.WERKSDto; +import com.aucma.base.domain.BaseMaterialInfo; +import com.aucma.common.core.domain.AjaxResult; +import com.aucma.report.service.IRecordElectricalInspectionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author YinQ + * @create 2023-09-26 14:29 + */ +@RestController +@RequestMapping("/webApi") +public class ElectricalInspectionController { + + + @Autowired + private IRecordElectricalInspectionService electricalInspectionService; + + + /** + * 解析电检数据接口 + * @param paramMap + * @return + */ + @PostMapping("/electricalInspection") + public HashMap getSAPMaterialData(@RequestBody Map paramMap) { + return electricalInspectionService.analysisElectricalInspectionData(paramMap); + } + + + +} diff --git a/aucma-framework/src/main/java/com/aucma/framework/config/SecurityConfig.java b/aucma-framework/src/main/java/com/aucma/framework/config/SecurityConfig.java index 9e848d1..283d32d 100644 --- a/aucma-framework/src/main/java/com/aucma/framework/config/SecurityConfig.java +++ b/aucma-framework/src/main/java/com/aucma/framework/config/SecurityConfig.java @@ -125,6 +125,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter .antMatchers(HttpMethod.GET, "/report/pdaRecord/getPdaRecord").permitAll() .antMatchers(HttpMethod.GET, "/report/repairMeasures/getRepairMeasures").permitAll() .antMatchers(HttpMethod.GET, "/base/teamMembers/**").permitAll() + .antMatchers(HttpMethod.POST, "/webApi/electricalInspection").permitAll() .antMatchers(HttpMethod.POST, "/**/**/**").permitAll() .antMatchers(HttpMethod.GET, "/**/**/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 diff --git a/aucma-report/src/main/java/com/aucma/report/domain/ProductOffLine.java b/aucma-report/src/main/java/com/aucma/report/domain/ProductOffLine.java index 0c2a7b1..ea3072e 100644 --- a/aucma-report/src/main/java/com/aucma/report/domain/ProductOffLine.java +++ b/aucma-report/src/main/java/com/aucma/report/domain/ProductOffLine.java @@ -35,9 +35,9 @@ public class ProductOffLine extends BaseEntity { private String productSncode; /** - * 工单号 + * SAP计划编号 */ - @Excel(name = "工单号") + @Excel(name = "SAP计划编号") private String productOrderNo; /** diff --git a/aucma-report/src/main/java/com/aucma/report/mapper/RecordElectricalInspectionMapper.java b/aucma-report/src/main/java/com/aucma/report/mapper/RecordElectricalInspectionMapper.java index e703cbe..76e879f 100644 --- a/aucma-report/src/main/java/com/aucma/report/mapper/RecordElectricalInspectionMapper.java +++ b/aucma-report/src/main/java/com/aucma/report/mapper/RecordElectricalInspectionMapper.java @@ -79,7 +79,7 @@ public interface RecordElectricalInspectionMapper * @return 结果 */ public int batchDetailElectricalinspection(List detailElectricalinspectionList); - + /** * 通过电检数据记录主键删除电检数据明细信息 @@ -88,4 +88,7 @@ public interface RecordElectricalInspectionMapper * @return 结果 */ public int deleteDetailElectricalinspectionByUuid(String uuid); + + public int insertDetailElectricalinspection(DetailElectricalinspection detailElectricalinspection); + } diff --git a/aucma-report/src/main/java/com/aucma/report/service/IRecordElectricalInspectionService.java b/aucma-report/src/main/java/com/aucma/report/service/IRecordElectricalInspectionService.java index ce080cf..93a87ff 100644 --- a/aucma-report/src/main/java/com/aucma/report/service/IRecordElectricalInspectionService.java +++ b/aucma-report/src/main/java/com/aucma/report/service/IRecordElectricalInspectionService.java @@ -1,6 +1,9 @@ package com.aucma.report.service; +import java.util.HashMap; import java.util.List; +import java.util.Map; + import com.aucma.report.domain.RecordElectricalInspection; /** @@ -58,4 +61,11 @@ public interface IRecordElectricalInspectionService * @return 结果 */ public int deleteRecordElectricalInspectionByUuid(String uuid); + + /** + * 解析电检数据接口 + * @param paramMap + * @return + */ + HashMap analysisElectricalInspectionData(Map paramMap); } diff --git a/aucma-report/src/main/java/com/aucma/report/service/impl/RecordElectricalInspectionServiceImpl.java b/aucma-report/src/main/java/com/aucma/report/service/impl/RecordElectricalInspectionServiceImpl.java index e281c1f..cccfc12 100644 --- a/aucma-report/src/main/java/com/aucma/report/service/impl/RecordElectricalInspectionServiceImpl.java +++ b/aucma-report/src/main/java/com/aucma/report/service/impl/RecordElectricalInspectionServiceImpl.java @@ -1,9 +1,18 @@ package com.aucma.report.service.impl; +import java.util.HashMap; import java.util.List; + +import com.aucma.common.utils.DateUtils; +import com.aucma.common.utils.uuid.UUID; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + import java.util.ArrayList; +import java.util.Map; + import com.aucma.common.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; import com.aucma.report.domain.DetailElectricalinspection; @@ -13,50 +22,48 @@ import com.aucma.report.service.IRecordElectricalInspectionService; /** * 电检数据记录Service业务层处理 - * + * * @author Yinq * @date 2023-11-09 */ @Service -public class RecordElectricalInspectionServiceImpl implements IRecordElectricalInspectionService -{ +public class RecordElectricalInspectionServiceImpl implements IRecordElectricalInspectionService { + private static final Logger logger = LoggerFactory.getLogger(RecordElectricalInspectionServiceImpl.class); + @Autowired private RecordElectricalInspectionMapper recordElectricalInspectionMapper; /** * 查询电检数据记录 - * + * * @param uuid 电检数据记录主键 * @return 电检数据记录 */ @Override - public RecordElectricalInspection selectRecordElectricalInspectionByUuid(String uuid) - { + public RecordElectricalInspection selectRecordElectricalInspectionByUuid(String uuid) { return recordElectricalInspectionMapper.selectRecordElectricalInspectionByUuid(uuid); } /** * 查询电检数据记录列表 - * + * * @param recordElectricalInspection 电检数据记录 * @return 电检数据记录 */ @Override - public List selectRecordElectricalInspectionList(RecordElectricalInspection recordElectricalInspection) - { + public List selectRecordElectricalInspectionList(RecordElectricalInspection recordElectricalInspection) { return recordElectricalInspectionMapper.selectRecordElectricalInspectionList(recordElectricalInspection); } /** * 新增电检数据记录 - * + * * @param recordElectricalInspection 电检数据记录 * @return 结果 */ @Transactional @Override - public int insertRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection) - { + public int insertRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection) { int rows = recordElectricalInspectionMapper.insertRecordElectricalInspection(recordElectricalInspection); insertDetailElectricalinspection(recordElectricalInspection); return rows; @@ -64,14 +71,13 @@ public class RecordElectricalInspectionServiceImpl implements IRecordElectricalI /** * 修改电检数据记录 - * + * * @param recordElectricalInspection 电检数据记录 * @return 结果 */ @Transactional @Override - public int updateRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection) - { + public int updateRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection) { recordElectricalInspectionMapper.deleteDetailElectricalinspectionByUuid(recordElectricalInspection.getUuid()); insertDetailElectricalinspection(recordElectricalInspection); return recordElectricalInspectionMapper.updateRecordElectricalInspection(recordElectricalInspection); @@ -79,53 +85,99 @@ public class RecordElectricalInspectionServiceImpl implements IRecordElectricalI /** * 批量删除电检数据记录 - * + * * @param uuids 需要删除的电检数据记录主键 * @return 结果 */ @Transactional @Override - public int deleteRecordElectricalInspectionByUuids(String[] uuids) - { + public int deleteRecordElectricalInspectionByUuids(String[] uuids) { recordElectricalInspectionMapper.deleteDetailElectricalinspectionByUuids(uuids); return recordElectricalInspectionMapper.deleteRecordElectricalInspectionByUuids(uuids); } /** * 删除电检数据记录信息 - * + * * @param uuid 电检数据记录主键 * @return 结果 */ @Transactional @Override - public int deleteRecordElectricalInspectionByUuid(String uuid) - { + public int deleteRecordElectricalInspectionByUuid(String uuid) { recordElectricalInspectionMapper.deleteDetailElectricalinspectionByUuid(uuid); return recordElectricalInspectionMapper.deleteRecordElectricalInspectionByUuid(uuid); } + /** * 新增电检数据明细信息 - * + * * @param recordElectricalInspection 电检数据记录对象 */ - public void insertDetailElectricalinspection(RecordElectricalInspection recordElectricalInspection) - { + public void insertDetailElectricalinspection(RecordElectricalInspection recordElectricalInspection) { List detailElectricalinspectionList = recordElectricalInspection.getDetailElectricalinspectionList(); String uuid = recordElectricalInspection.getUuid(); - if (StringUtils.isNotNull(detailElectricalinspectionList)) - { + if (StringUtils.isNotNull(detailElectricalinspectionList)) { List list = new ArrayList(); - for (DetailElectricalinspection detailElectricalinspection : detailElectricalinspectionList) - { + for (DetailElectricalinspection detailElectricalinspection : detailElectricalinspectionList) { detailElectricalinspection.setUuid(uuid); list.add(detailElectricalinspection); } - if (list.size() > 0) - { + if (list.size() > 0) { recordElectricalInspectionMapper.batchDetailElectricalinspection(list); } } } + + + /** + * 解析电检数据接口 + * + * @param paramMap + * @return + */ + @Override + public HashMap analysisElectricalInspectionData(Map paramMap) { + HashMap resultData = new HashMap<>(); + RecordElectricalInspection inspection = new RecordElectricalInspection(); + String uuid = String.valueOf(paramMap.get("uuid")); + try { + String result = String.valueOf(paramMap.get("result")); + String barcode = String.valueOf(paramMap.get("barcode")); + String testdata = String.valueOf(paramMap.get("testdata")); + String testtime = String.valueOf(paramMap.get("testtime")); + inspection.setUuid(UUID.randomUUID().toString()); + inspection.setResult(result); + inspection.setBarcode(barcode); + if (StringUtils.isNull(testtime)) { + testtime = DateUtils.dateTime(); + } + inspection.setTestTime(testtime); + inspection.setTestData(uuid); + inspection.setRecordTime(DateUtils.getNowDate()); + recordElectricalInspectionMapper.insertRecordElectricalInspection(inspection); + String[] testDataEntries = testdata.split(";"); + for (String testDataEntry : testDataEntries) { + String[] testDataParts = testDataEntry.split("\\|"); + if (testDataParts.length == 5) { + DetailElectricalinspection testData = new DetailElectricalinspection(); + testData.setUuid(uuid); + testData.setSerialnumber(Long.parseLong(testDataParts[0])); + testData.setProjectname(testDataParts[1]); + testData.setTestcondition(testDataParts[2]); + testData.setTestvalue(testDataParts[3]); + testData.setTestresult(testDataParts[4]); + testData.setRecordtime(DateUtils.getNowDate()); + recordElectricalInspectionMapper.insertDetailElectricalinspection(testData); + } + } + } catch (Exception e) { + logger.error("解析电检数据接口数据:" + paramMap.toString() + ";异常:" + e); + } + resultData.put("uuid", uuid); + resultData.put("answer", "OK"); + return resultData; + } + } diff --git a/aucma-report/src/main/resources/mapper/report/ProductOffLineMapper.xml b/aucma-report/src/main/resources/mapper/report/ProductOffLineMapper.xml index 514c2c8..5e5dc2c 100644 --- a/aucma-report/src/main/resources/mapper/report/ProductOffLineMapper.xml +++ b/aucma-report/src/main/resources/mapper/report/ProductOffLineMapper.xml @@ -66,7 +66,8 @@ #{productFactoryCode} and po.product_sncode = #{productSncode} - and po.product_order_no = #{productOrderNo} + and po.product_order_no like concat(concat('%', + #{product_order_no}), '%') and po.product_sale_no = #{productSaleNo} and po.product_sale_line_no = #{productSaleLineNo} diff --git a/aucma-report/src/main/resources/mapper/report/RecordElectricalInspectionMapper.xml b/aucma-report/src/main/resources/mapper/report/RecordElectricalInspectionMapper.xml index 254f227..f424d5a 100644 --- a/aucma-report/src/main/resources/mapper/report/RecordElectricalInspectionMapper.xml +++ b/aucma-report/src/main/resources/mapper/report/RecordElectricalInspectionMapper.xml @@ -137,4 +137,11 @@ SELECT 1 FROM DUAL + + + INSERT INTO detail_electricalinspection( uuid, serialnumber, projectname, testcondition, testvalue, testresult, + recordtime) values ( #{uuid}, #{serialnumber}, #{projectname}, #{testcondition}, + #{testvalue}, #{testresult}, #{recordtime}) + + \ No newline at end of file