检验报告同步
This commit is contained in:
parent
d7cdc490b7
commit
fa1105ccf2
|
|
@ -12,6 +12,7 @@ import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
|||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.material.basic.domain.BmQrcodeInfo;
|
||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||
import com.bonus.material.ma.domain.MachineSynch;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
import com.bonus.material.ma.domain.vo.MachineVo;
|
||||
import com.bonus.material.ma.domain.vo.SampleSync;
|
||||
|
|
@ -315,6 +316,29 @@ public class MachineController extends BaseController {
|
|||
return machineService.synchReport(machine);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询检验报告同步记录
|
||||
*/
|
||||
@ApiOperation(value = "查询检验报告同步记录")
|
||||
//@RequiresPermissions("ma:machine:list")
|
||||
@GetMapping("/getSynchList")
|
||||
public TableDataInfo getSynchList(MachineSynch machine) {
|
||||
startPage();
|
||||
List<MachineSynch> list = machineService.selectSynchList(machine);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "查询检验报告同步记录")
|
||||
//@RequiresPermissions("ma:machine:list")
|
||||
@GetMapping("/getSynchDetailList")
|
||||
public TableDataInfo getSynchDetailList(MachineSynch machine) {
|
||||
startPage();
|
||||
List<MachineSynch> list = machineService.selectSynchDetailList(machine);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 固定资产编号录入
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ public class Machine extends BaseEntity {
|
|||
*/
|
||||
private Long maId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 类型ID
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -44,4 +44,12 @@ public class SampleSync extends BaseEntity
|
|||
private String reportName;
|
||||
|
||||
private String reportNum;
|
||||
|
||||
private int maStatus;
|
||||
|
||||
private int isSuccess;
|
||||
|
||||
private String typeNameCode;
|
||||
|
||||
private int parentId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
|||
import com.bonus.material.basic.domain.BmQrBoxInfo;
|
||||
import com.bonus.material.basic.domain.dto.BoxBindWarehouseDto;
|
||||
import com.bonus.material.ma.domain.Machine;
|
||||
import com.bonus.material.ma.domain.MachineSynch;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
import com.bonus.material.ma.domain.vo.MachineVo;
|
||||
import com.bonus.material.ma.domain.vo.SampleSync;
|
||||
|
|
@ -236,4 +237,16 @@ public interface MachineMapper
|
|||
* @return
|
||||
*/
|
||||
int getCountByMaCode(Machine machine);
|
||||
|
||||
SampleSync getSampleList(SampleSync sampleSync);
|
||||
|
||||
int batchInsertSynchDetails(@Param("list") List<SampleSync> samples);
|
||||
|
||||
List<MachineSynch> selectSynchList(MachineSynch machine);
|
||||
|
||||
List<SampleSync> getBigList(List<SampleSync> samples);
|
||||
|
||||
void insertInfo(Machine machine);
|
||||
|
||||
List<MachineSynch> selectSynchDetailList(MachineSynch machine);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
|||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
|
||||
import com.bonus.material.ma.domain.Machine;
|
||||
import com.bonus.material.ma.domain.MachineSynch;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
import com.bonus.material.ma.domain.vo.MachineVo;
|
||||
|
||||
|
|
@ -154,4 +155,8 @@ public interface IMachineService
|
|||
* @return 结果
|
||||
*/
|
||||
AjaxResult addMaMachine(Machine machine);
|
||||
|
||||
List<MachineSynch> selectSynchList(MachineSynch machine);
|
||||
|
||||
List<MachineSynch> selectSynchDetailList(MachineSynch machine);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.bonus.material.ma.service.impl;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
|
|
@ -12,10 +9,12 @@ import com.bonus.common.biz.enums.HttpCodeEnum;
|
|||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
|
||||
import com.bonus.material.lease.domain.vo.LeaseOutVo;
|
||||
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
||||
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
|
||||
import com.bonus.material.ma.domain.MachineSynch;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
import com.bonus.material.ma.domain.vo.MachineVo;
|
||||
import com.bonus.material.ma.domain.vo.SampleSync;
|
||||
|
|
@ -311,8 +310,17 @@ public class MachineServiceImpl implements IMachineService
|
|||
String nextCheckTime = machine.getNextCheckTimeSynch() + " 00:00:00";
|
||||
String reportName = machine.getReportName();
|
||||
String reportNum = machine.getReportNum();
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
machine.setUserId(userId);
|
||||
//往主表插入
|
||||
Machine machineTemp = new Machine();
|
||||
machineTemp.setReportNum(machine.getReportNum());
|
||||
machineTemp.setUserId(userId);
|
||||
|
||||
machineMapper.insertInfo(machineTemp);
|
||||
int newId = Math.toIntExact(machineTemp.getId());
|
||||
List<SampleSync> samples = machine.getSamples();
|
||||
|
||||
if(samples != null && !samples.isEmpty()){
|
||||
// 批量设置属性
|
||||
for(SampleSync sample : samples){
|
||||
|
|
@ -321,15 +329,131 @@ public class MachineServiceImpl implements IMachineService
|
|||
sample.setPdf(pdfUrl);
|
||||
sample.setReportName(reportName);
|
||||
sample.setReportNum(reportNum);
|
||||
sample.setTypeNameCode(sample.getSampleName() + "-" + sample.getSelfCode());
|
||||
sample.setParentId(newId);
|
||||
}
|
||||
//找出大类ma_code
|
||||
List<SampleSync> bigList = machineMapper.getBigList(samples);
|
||||
|
||||
//丢失、报废、不存在的编号都为异常,不合格
|
||||
//1.初始化分类列表
|
||||
List<SampleSync> lostList = new ArrayList<>();
|
||||
List<SampleSync> scrapList = new ArrayList<>();
|
||||
List<SampleSync> notExistList = new ArrayList<>();
|
||||
List<SampleSync> successList = new ArrayList<>(); // 原sueecssList修正拼写
|
||||
List<SampleSync> exceptionList = new ArrayList<>(); // 新增异常列表
|
||||
|
||||
//2.构建bigList的typeNameCode映射表(优化查询效率)
|
||||
Map<String, List<SampleSync>> typeNameCodeMap = new HashMap<>();
|
||||
for (SampleSync bigItem : bigList) {
|
||||
String key = bigItem.getTypeNameCode();
|
||||
typeNameCodeMap.computeIfAbsent(key, k -> new ArrayList<>()).add(bigItem);
|
||||
}
|
||||
|
||||
//3.遍历samples进行分类
|
||||
for (SampleSync sample : samples) {
|
||||
String sampleTypeNameCode = sample.getTypeNameCode();
|
||||
List<SampleSync> matchedBigItems = typeNameCodeMap.getOrDefault(sampleTypeNameCode, Collections.emptyList());
|
||||
|
||||
if (matchedBigItems.isEmpty()) {
|
||||
//无匹配项
|
||||
sample.setResult("未发现该机具");
|
||||
sample.setIsSuccess(0);
|
||||
notExistList.add(sample);
|
||||
} else if (matchedBigItems.size() > 1) {
|
||||
//匹配超过1个,存入异常列表
|
||||
sample.setResult("该机具编码重复");
|
||||
sample.setIsSuccess(0);
|
||||
exceptionList.add(sample);
|
||||
} else {
|
||||
//仅匹配1个,检查maStatus
|
||||
SampleSync matchedItem = matchedBigItems.get(0);
|
||||
Integer maStatus = matchedItem.getMaStatus();
|
||||
|
||||
if (maStatus != null) {
|
||||
// 根据现有业务逻辑,6/7/8/10代表"报废",18代表"丢失"
|
||||
if (maStatus == 6 || maStatus == 7 || maStatus == 8 || maStatus == 10) {
|
||||
sample.setResult("该机具已报废");
|
||||
sample.setIsSuccess(0);
|
||||
scrapList.add(sample);
|
||||
} else if (maStatus == 18) {
|
||||
sample.setResult("该机具已丢失");
|
||||
sample.setIsSuccess(0);
|
||||
lostList.add(sample);
|
||||
} else {
|
||||
sample.setIsSuccess(1);
|
||||
// 非报废/丢失状态,暂存入成功列表(可根据实际业务调整)
|
||||
successList.add(sample);
|
||||
}
|
||||
} else {
|
||||
// maStatus为空,视为未匹配
|
||||
notExistList.add(sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //丢失、报废、不存在的编号都为异常,不合格
|
||||
// //1.查询过滤出来报废的机具编码
|
||||
// List lostList = new ArrayList<>();
|
||||
// List scrapList = new ArrayList<>();
|
||||
// List notExistList = new ArrayList<>();
|
||||
// List sueecssList = new ArrayList<>();
|
||||
// SampleSync sampleOne = new SampleSync();
|
||||
// for (int i = 0; i < samples.size(); i++) {
|
||||
// sampleOne = machineMapper.getSampleList(samples.get(i));
|
||||
// if(sampleOne != null && (sampleOne.getMaStatus() == 6 || sampleOne.getMaStatus() == 7 || sampleOne.getMaStatus() == 8 || sampleOne.getMaStatus() == 10)){
|
||||
// samples.get(i).setResult("该机具已报废");
|
||||
// samples.get(i).setIsSuccess(0);
|
||||
// scrapList.add(samples.get(i));
|
||||
// }else if(sampleOne != null && sampleOne.getMaStatus() == 18){
|
||||
// samples.get(i).setResult("该机具已报废");
|
||||
// samples.get(i).setIsSuccess(0);
|
||||
// scrapList.add(samples.get(i));
|
||||
// }else if(sampleOne != null){
|
||||
// samples.get(i).setIsSuccess(1);
|
||||
// sueecssList.add(samples.get(i));
|
||||
// }else{
|
||||
// samples.get(i).setResult("未发现该机具");
|
||||
// samples.get(i).setIsSuccess(0);
|
||||
// notExistList.add(samples.get(i));
|
||||
// }
|
||||
// }
|
||||
//对数据进行汇总
|
||||
List<SampleSync> allList = new ArrayList<>();
|
||||
allList.addAll(lostList);
|
||||
allList.addAll(scrapList);
|
||||
allList.addAll(notExistList);
|
||||
allList.addAll(successList);
|
||||
allList.addAll(exceptionList);
|
||||
|
||||
|
||||
// 使用批量更新
|
||||
int numAll = machineMapper.batchUpdateSynchReport(samples);
|
||||
if(successList != null && !successList.isEmpty()){
|
||||
int numAll = machineMapper.batchUpdateSynchReport(successList);
|
||||
//异常和合格的都插入到记录表
|
||||
int num = machineMapper.batchInsertSynchDetails(allList);
|
||||
if(numAll > 0){
|
||||
return success("同步成功,更新了 " + numAll + " 条记录");
|
||||
}else{
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return error("同步失败,暂无相关的机具编码");
|
||||
}
|
||||
}else{
|
||||
//异常和合格的都插入到记录表
|
||||
int num = machineMapper.batchInsertSynchDetails(allList);
|
||||
return error("同步失败,暂无相关的机具编码");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return error("同步失败,暂无相关的机具编码");
|
||||
|
|
@ -634,5 +758,13 @@ public class MachineServiceImpl implements IMachineService
|
|||
return machineMapper.getInfoByTypeId(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MachineSynch> selectSynchList(MachineSynch machine) {
|
||||
return machineMapper.selectSynchList(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MachineSynch> selectSynchDetailList(MachineSynch machine) {
|
||||
return machineMapper.selectSynchDetailList(machine);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1064,4 +1064,110 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE ma_code = #{maCode}
|
||||
and type_id = #{typeId}
|
||||
</select>
|
||||
<select id="getSampleList" resultType="com.bonus.material.ma.domain.vo.SampleSync">
|
||||
select
|
||||
ma_code as maCode,
|
||||
ma_status as maStatus
|
||||
from ma_machine
|
||||
where ma_code = #{selfCode}
|
||||
limit 1
|
||||
</select>
|
||||
<select id="selectSynchDetailList" resultType="com.bonus.material.ma.domain.MachineSynch">
|
||||
select
|
||||
mcd.ma_code as maCode,
|
||||
mcd.check_man as checkMan,
|
||||
DATE_FORMAT(mcd.this_check_time, '%Y-%m-%d') as checkTimeSynch,
|
||||
DATE_FORMAT(mcd.next_check_time, '%Y-%m-%d') as nextCheckTimeSynch,
|
||||
mcd.is_success as isSuccess,
|
||||
mcd.reason as result,
|
||||
mcd.ex_code as reportNum,
|
||||
mt.type_id as typeId,
|
||||
mt2.type_name as typeModelName,
|
||||
mt.type_name as typeName
|
||||
from ma_check_details mcd
|
||||
left join ma_machine mm on mcd.ma_code = mm.ma_code
|
||||
left join ma_type mt on mm.type_id = mt.type_id
|
||||
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
||||
where
|
||||
mcd.parent_id = #{parentId}
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
mcd.ma_code like concat('%', #{keyWord}, '%')
|
||||
or mcd.reason like concat('%', #{keyWord}, '%')
|
||||
or mcd.ex_code like concat('%', #{keyWord}, '%')
|
||||
or mt2.type_name like concat('%', #{keyWord}, '%')
|
||||
or mt.type_name like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectSynchList" resultType="com.bonus.material.ma.domain.MachineSynch">
|
||||
select
|
||||
mci.id as id,
|
||||
mci.ex_code as reportNum,
|
||||
mci.create_time as createTime,
|
||||
su.nick_name as createBy
|
||||
from ma_check_info mci
|
||||
left join sys_user su on mci.create_by = su.user_id
|
||||
<where>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
(
|
||||
mci.ex_code like concat('%', #{keyWord}, '%')
|
||||
or su.nick_name like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getBigList" resultType="com.bonus.material.ma.domain.vo.SampleSync">
|
||||
select
|
||||
CONCAT_WS('-', mt2.type_name, mm.ma_code) as typeNameCode,
|
||||
mm.ma_code as maCode,
|
||||
mm.ma_status as maStatus
|
||||
from ma_machine mm
|
||||
left join ma_type mt on mm.type_id = mt.type_id
|
||||
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
||||
where mt.jiju_type = 2
|
||||
</select>
|
||||
|
||||
<insert id="batchInsertSynchDetails" >
|
||||
INSERT INTO ma_check_details (
|
||||
parent_id,
|
||||
ma_code,
|
||||
check_man,
|
||||
this_check_time,
|
||||
next_check_time,
|
||||
is_success,
|
||||
reason,
|
||||
ex_code,
|
||||
type_name
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.parentId},
|
||||
#{item.selfCode},
|
||||
#{item.tester},
|
||||
#{item.checkTimeSynch},
|
||||
#{item.nextCheckTimeSynch},
|
||||
#{item.isSuccess},
|
||||
#{item.result},
|
||||
#{item.reportNum},
|
||||
#{item.sampleName}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="insertInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ma_check_info(
|
||||
ex_code,
|
||||
create_by,
|
||||
create_time
|
||||
)
|
||||
values(
|
||||
#{reportNum},
|
||||
#{userId},
|
||||
NOW()
|
||||
)
|
||||
|
||||
</insert>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue