报废+ocr

This commit is contained in:
mashuai 2025-01-03 14:07:12 +08:00
parent 5fa102fc3d
commit ba3fc88ce0
21 changed files with 1076 additions and 15 deletions

View File

@ -218,7 +218,8 @@ public class StoreLogAspect {
.map(RepairInputDetails::getMaCode)
.collect(Collectors.joining(","));
bmStorageLog.setMaCode(maCode);
bmStorageLog.setInputType(InputOutEnum.CODE_DEVICE.getTypeId());
bmStorageLog.setInputType(repairInputDetails.getInputType() != null ?
repairInputDetails.getInputType() : InputOutEnum.CODE_DEVICE.getTypeId() );
} else {
bmStorageLog.setManageType(String.valueOf(InputOutEnum.NUMBER_DEVICE.getTypeId()));
bmStorageLog.setInNum(repairInputDetails.getInputNum());

View File

@ -0,0 +1,98 @@
package com.bonus.common.biz.config;
import java.text.DecimalFormat;
/**
* @Author ma_sh
* @create 2025/1/2 15:03
*/
public class AppOcrConfig {
/**
* String字符串相似度比较
* @param str
* @param target
* @param isIgnore
* @return
*/
public static float getSimilarityRatio(String str, String target, boolean isIgnore) {
float ret = 0;
DecimalFormat decimalFormat=new DecimalFormat(".0");
if (Math.max(str.length(), target.length()) == 0) {
ret = 1;
} else {
ret = 1 - (float) compare(str, target, isIgnore) / Math.max(str.length(), target.length());
}
ret=Float.parseFloat(decimalFormat.format(ret*100));
return ret;
}
/**
* 字符串相似度比较
* @param str
* @param target
* @param isIgnore
* @return
*/
public static int compare(String str, String target, boolean isIgnore) {
int[][] d; // 矩阵
int n = str.length();
int m = target.length();
int i; // 遍历str的
int j; // 遍历target的
char ch1; // str的
char ch2; // target的
int temp; // 记录相同字符,在某个矩阵位置值的增量,不是0就是1
if (n == 0) {
return m;
}
if (m == 0) {
return n;
}
d = new int[n + 1][m + 1];
for (i = 0; i <= n; i++) { // 初始化第一列
d[i][0] = i;
}
for (j = 0; j <= m; j++) { // 初始化第一行
d[0][j] = j;
}
for (i = 1; i <= n; i++) { // 遍历str
ch1 = str.charAt(i - 1);
// 去匹配target
for (j = 1; j <= m; j++) {
ch2 = target.charAt(j - 1);
if (isIgnore) {
if (ch1 == ch2 || ch1 == ch2 + 32 || ch1 + 32 == ch2) {
temp = 0;
} else {
temp = 1;
}
} else {
if (ch1 == ch2) {
temp = 0;
} else {
temp = 1;
}
}
// 左边+1,上边+1, 左上角+temp取最小
d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + temp);
}
}
return d[n][m];
}
/**
* 取最小值
* @param one
* @param two
* @param three
* @return
*/
public static int min(int one, int two, int three) {
return (one = Math.min(one, two)) < three ? one : three;
}
}

View File

@ -62,8 +62,8 @@ public class RepairInputDetails extends BaseEntity {
@ApiModelProperty(value = "机具状态")
private String maStatus;
@ApiModelProperty(value = "机具状态名称")
private String inputType;
@ApiModelProperty(value = "入库方式 0编码1数量2二维码3标准箱")
private Integer inputType;
@ApiModelProperty(value = "二维码code")
private String qrCode;

View File

@ -27,7 +27,8 @@ public enum MaMachineStatusEnum {
REPAIR_TO_SCRAP(7, "维修待报废"),
SCRAP_AUDIT(8, "已报废审核"),
BACK_TO_STORE(9, "退料待入库"),
SCRAP_TO_AUDIT(10, "报废待审核");
SCRAP_TO_AUDIT(10, "报废待审核"),
RETURNED_MATERIAL(11, "退料暂存");
private final Integer status;
private final String statusName;

View File

@ -0,0 +1,86 @@
package com.bonus.material.app.controller;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.app.domain.MachineOcrBean;
import com.bonus.material.app.service.AppOcrService;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.ma.domain.vo.MachineVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* app ocr扫描接口
* @Author ma_sh
* @create 2025/1/2 13:49
*/
@RestController
@RequestMapping("/app/ocr")
public class AppOcrController extends BaseController {
@Resource
private AppOcrService appOcrService;
/**
* 查询机具出库列表
* @param bean
* @return
*/
@GetMapping("/findByPage")
public AjaxResult findByPage(MachineOcrBean bean) {
startPage();
List<MachineOcrBean> list = appOcrService.findByPage(bean);
return AjaxResult.success(getDataTable(list));
}
/**
* 根据code查询机具出库列表
* @param bean
* @return
*/
@GetMapping("/findOutListByDeviceCode")
public AjaxResult findOutListByDeviceCode(MachineOcrBean bean) {
List<MachineVo> list = appOcrService.findOutListByDeviceCode(bean);
return AjaxResult.success(list);
}
/**
* 提交机具出库
* @param bean
* @return
*/
@ApiOperation(value = "提交机具出库")
@PreventRepeatSubmit
@PostMapping("/submitOcrOut")
public AjaxResult submitOcrOut(@RequestBody MachineOcrBean bean)
{
return appOcrService.submitOcrOut(bean);
}
/**
* 根据code查询机具退料列表
* @param bean
* @return
*/
@GetMapping("/findBackListByDeviceCode")
public AjaxResult findBackListByDeviceCode(MachineOcrBean bean) {
List<MachineVo> list = appOcrService.findBackListByDeviceCode(bean);
return AjaxResult.success(list);
}
/**
* 提交机具退料
* @param bean
* @return
*/
@ApiOperation(value = "提交机具退料")
@PreventRepeatSubmit
@PostMapping("/submitOcrBack")
public AjaxResult submitOcrBack(@RequestBody MachineOcrBean bean)
{
return appOcrService.submitOcrBack(bean);
}
}

View File

@ -0,0 +1,75 @@
package com.bonus.material.app.domain;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.Data;
/**
* @Author ma_sh
* @create 2025/1/2 13:54
*/
@Data
public class MachineOcrBean extends BaseEntity {
private String id;
private String epcCode;
private String deviceName;
private String deviceModel;
private String maCode;
private String batchStatus;
private String maId;
private String typeId;
private String userId;
private String companyId;
private String remark;
private String keyWord;
private String mStr;
private String taskId;
private String preOutNum;
private String alOutNum;
private String thisOutNum;
private String type;
private String outTime;
private String repairTime;
private String nextRepairTime;
private String days;
private String pickId;
private String deptId;
private String subId;
private String teamId;
private String rearId;
private String initType;
private String projectId;
private String maType;
private String maDeviceCode;
private String maCount;
private String maModel;
private String maModelId;
private String outNum;
private String backNum;
private String repairNum;
private String backStatus;
private String backTypeId;
private String supplierId;
private String exampleId;
private String purchasePrice;
private String buyTime;
private String outCode;
private String actualNum;
private String qualifiedNum;
private String proName;
private String deptName;
private String unitId;
private String linkMan;
private String model;
private String code;
private String result;
private String exName;
private String exCode;
private String exUrl;
}

View File

@ -0,0 +1,50 @@
package com.bonus.material.app.mapper;
import com.bonus.material.app.domain.MachineOcrBean;
import com.bonus.material.ma.domain.vo.MachineVo;
import java.util.List;
/**
* @ClassName AppOcrMapper
* @Author ma_sh
* @create 2025/1/2 13:51
*/
public interface AppOcrMapper {
/**
* 查询机具出库列表
* @param bean
* @return
*/
List<MachineOcrBean> findByPage(MachineOcrBean bean);
/**
* 根据设备编号查询机具出库列表
* @param bean
* @return
*/
List<MachineVo> findListByDeviceCode(MachineOcrBean bean);
/**
* 添加机具出库记录
* @param o
*/
void addOcrRecord(MachineOcrBean o);
/**
* 根据设备编号查询机具编码
* @param o
* @return
*/
List<MachineVo> findCodeList(MachineOcrBean o);
/**
* 更新机具入库数据
* @param bean
* @return
*/
int updateStorageData(MachineOcrBean bean);
int updateStorageDataBack(MachineOcrBean bean);
}

View File

@ -0,0 +1,50 @@
package com.bonus.material.app.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.app.domain.MachineOcrBean;
import com.bonus.material.ma.domain.vo.MachineVo;
import java.util.List;
/**
* @ClassName AppOcrService
* @Author ma_sh
* @create 2025/1/2 13:50
*/
public interface AppOcrService {
/**
* 提交机具出库
* @param bean
* @return
*/
AjaxResult submitOcrOut(MachineOcrBean bean);
/**
* 查询机具出库列表
* @param bean
* @return
*/
List<MachineOcrBean> findByPage(MachineOcrBean bean);
/**
* 根据code查询机具出库列表
* @param bean
* @return
*/
List<MachineVo> findOutListByDeviceCode(MachineOcrBean bean);
/**
* 根据code查询机具退料列表
* @param bean
* @return
*/
List<MachineVo> findBackListByDeviceCode(MachineOcrBean bean);
/**
* 提交机具退料
* @param bean
* @return
*/
AjaxResult submitOcrBack(MachineOcrBean bean);
}

View File

@ -0,0 +1,250 @@
package com.bonus.material.app.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.config.AppOcrConfig;
import com.bonus.common.biz.enums.HttpCodeEnum;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.app.domain.MachineOcrBean;
import com.bonus.material.app.mapper.AppOcrMapper;
import com.bonus.material.app.service.AppOcrService;
import com.bonus.material.ma.domain.Machine;
import com.bonus.material.ma.domain.vo.MachineVo;
import com.bonus.material.ma.mapper.MachineMapper;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.internal.util.StringHelper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName AppOcrServiceImpl
* @Author ma_sh
* @create 2025/1/2 13:50
*/
@Service
@Slf4j
public class AppOcrServiceImpl implements AppOcrService {
@Resource
private AppOcrMapper appOcrMapper;
@Resource
private MachineMapper machineMapper;
/**
* 提交机具出库
* @param bean
* @return
*/
@Override
public AjaxResult submitOcrOut(MachineOcrBean bean) {
int res = 0;
try {
String taskId = bean.getTaskId();
// --------------bpm_example修改状态发料进行中------------
//res = updateTaskStatus(bean,taskId);
String maId = bean.getMaId();
MachineVo ma = machineMapper.selectMachineByMaId(Long.parseLong(maId));
if (ma != null) {
// --------------bpm_pick_form修改数据--------------------
//res = updateFormData(bean,taskId,pickId);
// --------------ma_machine修改状态-------bpm_pick_form_details插入数据---------------
ma.setMaStatus("2");
res = updateMaStatus(bean, ma, taskId);
if (res > 0) {
// --------------ma_machine_type修改库存在用------------
res = updateStorageData(bean, taskId);
if (res > 0) {
log.info("maId:" + maId + "出库成功!");
} else {
throw new RuntimeException("修改ma_machine_type信息失败!");
}
} else {
throw new RuntimeException("修改ma_machine信息失败!");
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (res > 0) {
return AjaxResult.success("出库成功");
}
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
* 修改库存数据
* @param bean
* @param taskId
* @return
*/
private int updateStorageData(MachineOcrBean bean, String taskId) {
bean.setOutNum("1");
return appOcrMapper.updateStorageData(bean);
}
/**
* 修改机具状态
* @param bean
* @param ma
* @param taskId
* @return
*/
private int updateMaStatus(MachineOcrBean bean, MachineVo ma, String taskId) {
Machine machine = new Machine();
machine.setMaId(Long.parseLong(bean.getMaId()));
machine.setUpdateTime(DateUtils.getNowDate());
machine.setMaStatus(ma.getMaStatus());
return machineMapper.updateMachine(machine);
}
/**
* 查询机具出库列表
* @param bean
* @return
*/
@Override
public List<MachineOcrBean> findByPage(MachineOcrBean bean) {
return appOcrMapper.findByPage(bean);
}
/**
* 根据code查询机具出库列表
* @param bean
* @return
*/
@Override
public List<MachineVo> findOutListByDeviceCode(MachineOcrBean bean) {
List<MachineVo> codeList = appOcrMapper.findListByDeviceCode(bean);
if (CollectionUtils.isNotEmpty(codeList)) {
MachineOcrBean o= new MachineOcrBean();
o.setModel("出库");
o.setCode(bean.getMaCode());
o.setResult("1");
o.setCreateBy(SecurityUtils.getUsername());
appOcrMapper.addOcrRecord(o);
return codeList;
} else {
MachineOcrBean o= new MachineOcrBean();
o.setModel("出库");
o.setCode(bean.getMaCode());
o.setResult("0");
o.setCreateBy(SecurityUtils.getUsername());
appOcrMapper.addOcrRecord(o);
List<MachineVo> rsList = new ArrayList<>();
String ocrCode = o.getMaCode();
List<MachineVo> stList = appOcrMapper.findCodeList(o);
for(MachineVo m : stList){
String code = m.getMaCode();
float rsNum = AppOcrConfig.getSimilarityRatio(ocrCode, code, true);
if(rsNum > 91){
rsList.add(m);
}
}
if (CollectionUtils.isNotEmpty(rsList)) {
return rsList;
}
}
return null;
}
/**
* 根据code查询机具退料列表
* @param bean
* @return
*/
@Override
public List<MachineVo> findBackListByDeviceCode(MachineOcrBean bean) {
List<MachineVo> codeList = appOcrMapper.findListByDeviceCode(bean);
if (CollectionUtils.isNotEmpty(codeList)) {
MachineOcrBean o= new MachineOcrBean();
o.setModel("退料");
o.setCode(bean.getMaCode());
o.setResult("1");
o.setCreateBy(SecurityUtils.getUsername());
appOcrMapper.addOcrRecord(o);
return codeList;
} else {
MachineOcrBean o= new MachineOcrBean();
o.setModel("退料");
o.setCode(bean.getMaCode());
o.setResult("0");
o.setCreateBy(SecurityUtils.getUsername());
appOcrMapper.addOcrRecord(o);
List<MachineVo> rsList = new ArrayList<>();
String ocrCode = o.getMaCode();
List<MachineVo> stList = appOcrMapper.findCodeList(o);
for(MachineVo m : stList){
String code = m.getMaCode();
float rsNum = AppOcrConfig.getSimilarityRatio(ocrCode, code, true);
if(rsNum > 91){
rsList.add(m);
}
}
if (CollectionUtils.isNotEmpty(rsList)) {
return rsList;
}
}
return null;
}
/**
* 提交机具退料
* @param bean
* @return
*/
@Override
public AjaxResult submitOcrBack(MachineOcrBean bean) {
int res = 0;
try {
String taskId = bean.getTaskId();
// --------------bpm_example修改状态发料进行中------------
//res = updateTaskStatus(bean,taskId);
String maId = bean.getMaId();
MachineVo ma = machineMapper.selectMachineByMaId(Long.parseLong(maId));
if (ma != null) {
// --------------bpm_pick_form修改数据--------------------
//res = updateFormData(bean,taskId,pickId);
// --------------ma_machine修改状态-------bpm_pick_form_details插入数据---------------
ma.setMaStatus("1");
res = updateMaStatus(bean, ma, taskId);
if (res > 0) {
// --------------ma_machine_type修改库存在库------------
res = updateStorageDataBack(bean, taskId);
if (res > 0) {
log.info("maId:" + maId + "出库成功!");
} else {
throw new RuntimeException("修改ma_machine_type信息失败!");
}
} else {
throw new RuntimeException("修改ma_machine信息失败!");
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (res > 0) {
return AjaxResult.success("退料成功");
}
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
* 修改ma_machine_type库存在库
* @param bean
* @param taskId
* @return
*/
private int updateStorageDataBack(MachineOcrBean bean, String taskId) {
bean.setBackNum("1");
return appOcrMapper.updateStorageDataBack(bean);
}
}

View File

@ -354,8 +354,8 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
details.setApDetection(maCodeDto.getApDetection());
// 插入 CheckDetails
result += backApplyInfoMapper.insertCheckDetails(details);
//更新ma_machine表状态为3退料检修
//result += machineMapper.updateStatus(maCodeDto.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus());
//更新ma_machine表状态为11退料暂存
result += machineMapper.updateStatus(maCodeDto.getMaId(), MaMachineStatusEnum.RETURNED_MATERIAL.getStatus());
if (CollectionUtils.isNotEmpty(maCodeDto.getBmFileInfos())) {
for (BmFileInfo bmFileInfo : maCodeDto.getBmFileInfos()) {
bmFileInfo.setCreateBy(SecurityUtils.getUsername());
@ -737,8 +737,8 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
details.setPreNum(BigDecimal.valueOf(1));
// 插入 CheckDetails
result += backApplyInfoMapper.insertCheckDetails(details);
//更新ma_machine表状态为3退料检修
//result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus());
//更新ma_machine表状态为11退料暂存
result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.RETURNED_MATERIAL.getStatus());
if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) {
for (BmFileInfo bmFileInfo : details.getBmFileInfos()) {
bmFileInfo.setCreateBy(SecurityUtils.getUsername());

View File

@ -140,6 +140,16 @@ public class BmQrBoxController extends BaseController {
return qrBoxService.getBoxBindListByCode(bmQrBoxInfo);
}
/**
* APP -- 修饰入库 -- 扫码获取绑定物资信息
* @param bmQrBoxInfo
* @return
*/
@GetMapping("/getBoxCodeList")
public AjaxResult getBoxCodeList(@NotNull(message = "参数不能为空") BmQrBoxInfo bmQrBoxInfo) {
return qrBoxService.getBoxCodeList(bmQrBoxInfo);
}
/**
* APP -- 新购入库 -- 确认入库标准箱
*/

View File

@ -101,4 +101,11 @@ public interface BmQrBoxMapper {
* @return
*/
int deleteBoxBind(LeaseOutDetails record);
/**
* 根据二维码标准箱编码查询绑定详情
* @param bmQrBoxInfo
* @return
*/
List<BmQrBoxInfo> getBoxCodeList(BmQrBoxInfo bmQrBoxInfo);
}

View File

@ -103,4 +103,11 @@ public interface BmQrBoxService {
* @return
*/
AjaxResult getBoxBindListByCode(BmQrBoxInfo bmQrBoxInfo);
/**
* APP -- 修饰入库 -- 扫码获取绑定物资信息
* @param bmQrBoxInfo
* @return
*/
AjaxResult getBoxCodeList(BmQrBoxInfo bmQrBoxInfo);
}

View File

@ -468,4 +468,17 @@ public class BmQrBoxServiceImpl implements BmQrBoxService {
result.put("msg", msg);
return AjaxResult.success(result);
}
/**
* APP -- 修饰入库 -- 扫码获取绑定物资信息
* @param bmQrBoxInfo
* @return
*/
@Override
public AjaxResult getBoxCodeList(BmQrBoxInfo bmQrBoxInfo) {
if (null == bmQrBoxInfo.getBoxCode() || null == bmQrBoxInfo.getMaTypeId()) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "标准箱编码或机具类型id不能为空");
}
return AjaxResult.success(bmQrBoxMapper.getBoxCodeList(bmQrBoxInfo));
}
}

View File

@ -39,6 +39,18 @@ public class ScrapApplyDetails extends BaseEntity {
@ApiModelProperty(value = "任务ID")
private Long taskId;
@ApiModelProperty(value = "前任务ID")
private Long preTaskId;
@ApiModelProperty(value = "新任务ID")
private Long newTaskId;
@ApiModelProperty(value = "协议id")
private Long agreementId;
@ApiModelProperty(value = "退料id")
private Long backId;
@ApiModelProperty(value = "状态")
private String status;

View File

@ -74,4 +74,25 @@ public interface ScrapApplyDetailsMapper {
* @return
*/
int updateStatus(ScrapApplyDetails applyDetails);
/**
* 根据任务id查询上级id
* @param parentId
* @return
*/
Long selectBackIdByTaskId(Long parentId);
/**
* 修改物资状态
* @param applyDetails
* @return
*/
int updateMaStatus(ScrapApplyDetails applyDetails);
/**
* 新增退料
* @param applyDetails
* @return
*/
int insertRad(ScrapApplyDetails applyDetails);
}

View File

@ -1,17 +1,21 @@
package com.bonus.material.scrap.service.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.enums.HttpCodeEnum;
import com.bonus.common.biz.enums.RepairInputStatusEnum;
import com.bonus.common.biz.enums.ScrapTaskStatusEnum;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.enums.*;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.scrap.domain.vo.ScrapTaskListVo;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.domain.TmTaskAgreement;
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
import com.bonus.material.task.mapper.TmTaskMapper;
import org.springframework.stereotype.Service;
import com.bonus.material.scrap.mapper.ScrapApplyDetailsMapper;
@ -34,6 +38,9 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
@Resource
private TmTaskMapper taskMapper;
@Resource
private TmTaskAgreementMapper taskAgreementMapper;
/**
* 查询报废任务详细
*
@ -206,6 +213,131 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
*/
@Override
public AjaxResult reject(ScrapApplyDetails scrapApplyDetails) {
return null;
// TODO: 报废审核二级页面驳回
int result = 0;
if (scrapApplyDetails != null) {
if (CollectionUtils.isNotEmpty(scrapApplyDetails.getScrapApplyDetailsList())) {
//插入任务表
Long newTaskId = insertTt(scrapApplyDetails.getTaskId());
result += insertTta(newTaskId, scrapApplyDetails);
for (ScrapApplyDetails applyDetails : scrapApplyDetails.getScrapApplyDetailsList()) {
applyDetails.setStatus("2");
applyDetails.setAuditBy(SecurityUtils.getUserId());
applyDetails.setAuditTime(DateUtils.getNowDate());
result = scrapApplyDetailsMapper.updateStatus(applyDetails);
Long backId = scrapApplyDetailsMapper.selectBackIdByTaskId(applyDetails.getParentId());
applyDetails.setCreateBy(SecurityUtils.getUsername());
applyDetails.setCreateTime(DateUtils.getNowDate());
applyDetails.setBackId(backId);
applyDetails.setNewTaskId(newTaskId);
if (applyDetails.getMaId() != null) {
applyDetails.setStatus(MaMachineStatusEnum.BACK_REPAIR.getStatus().toString());
result += scrapApplyDetailsMapper.updateMaStatus(applyDetails);
}
result += insertWxTask(applyDetails);
}
if (result > 0) {
updateTaskStatus(scrapApplyDetails.getScrapApplyDetailsList().get(0));
}
// TODO: 报废审核一级页面驳回
} else if (CollectionUtils.isNotEmpty(scrapApplyDetails.getScrapTaskListVoList())) {
for (ScrapTaskListVo taskListVo : scrapApplyDetails.getScrapTaskListVoList()) {
// 根据任务id 查询任务详情
ScrapApplyDetails applyDetails = new ScrapApplyDetails();
applyDetails.setTaskId(taskListVo.getTaskId());
applyDetails.setAgreementId(taskListVo.getAgreementId());
//插入任务表
Long newTaskId = insertTt(taskListVo.getTaskId());
result += insertTta(newTaskId, applyDetails);
List<ScrapApplyDetails> scrapApplyDetailsList = scrapApplyDetailsMapper.selectRepairQuestListByTaskId(applyDetails);
// 将集合中status为0的筛选出来
if (CollectionUtils.isNotEmpty(scrapApplyDetailsList)) {
for (ScrapApplyDetails applyDetails1 : scrapApplyDetailsList) {
applyDetails1.setStatus("2");
applyDetails1.setAuditBy(SecurityUtils.getUserId());
applyDetails1.setAuditTime(DateUtils.getNowDate());
result = scrapApplyDetailsMapper.updateStatus(applyDetails1);
if (applyDetails1.getMaId() != null) {
applyDetails.setStatus(MaMachineStatusEnum.BACK_REPAIR.getStatus().toString());
result += scrapApplyDetailsMapper.updateMaStatus(applyDetails1);
}
Long backId = scrapApplyDetailsMapper.selectBackIdByTaskId(applyDetails1.getParentId());
applyDetails1.setCreateBy(SecurityUtils.getUsername());
applyDetails1.setCreateTime(DateUtils.getNowDate());
applyDetails1.setBackId(backId);
result += insertWxTask(applyDetails1);
}
}
if (result > 0) {
updateTaskStatus(applyDetails);
}
}
}
}
if (result > 0) {
return AjaxResult.success("驳回成功");
}
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
* 新增维修单
* @param applyDetails
* @return
*/
private int insertWxTask(ScrapApplyDetails applyDetails) {
return scrapApplyDetailsMapper.insertRad(applyDetails);
}
/**
* 驳回后重新生成维修单 插入任务表
* @return
*/
private Long insertTt(Long preTaskId) {
Long newTask = null;
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId());
// 生成维修单号
String code = genderWxTaskCode(thisMonthMaxOrder);
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
null,thisMonthMaxOrder + 1, code);
tmTask.setCreateTime(DateUtils.getNowDate());
tmTask.setCreateBy(SecurityUtils.getUsername());
tmTask.setPreTaskId(preTaskId);
// 插入任务
int taskId = taskMapper.insertTmTask(tmTask);
// 如果插入成功且返回的 taskId 大于 0
if (taskId > 0 && tmTask.getTaskId() > 0) {
newTask = tmTask.getTaskId();
}
return newTask;
}
/**
* 生成维修单号
* @param thisMonthMaxOrder
* @return
*/
private String genderWxTaskCode(int thisMonthMaxOrder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date nowDate = DateUtils.getNowDate();
String format = dateFormat.format(nowDate);
String result = format.replace("-", "");
return MaterialConstants.REPAIR_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
}
/**
* 插入协议任务表
* @param newTaskId
* @param scrapApplyDetails
* @return
*/
private int insertTta(Long newTaskId, ScrapApplyDetails scrapApplyDetails) {
int res;
String agreementId = String.valueOf(scrapApplyDetails.getAgreementId());
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(newTaskId, Long.parseLong(agreementId));
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
res = taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
return res;
}
}

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.material.archives.mapper.ArchivesMapper">
<mapper namespace="com.bonus.material.app.mapper.AppOcrMapper">
<select id="getTypeList" resultType="com.bonus.common.biz.domain.TreeNode">
select info_id as id, archives_name as label, parent_id as parentId,
@ -155,6 +155,140 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="findByPage" resultType="com.bonus.material.app.domain.MachineOcrBean">
SELECT id as id,
model as model,
`code` as code,
if(result="0","失败","成功") as result,
create_time as createTime
FROM
ma_ocr_record
where 1=1
<if test="keyWord !=null and keyWord !=''">
and(
model like concat('%', #{keyWord} ,'%')
or code like concat('%',#{keyWord} ,'%')
or result like concat('%',#{keyWord} ,'%')
)
</if>
</select>
<select id="findListByDeviceCode" resultType="com.bonus.material.ma.domain.vo.MachineVo">
SELECT
ma.ma_id as maId,
ma.type_id as typeId,
mt4.type_name as itemType,
mt3.type_name as materialType,
mt2.type_name as materialName,
mt.type_name as materialModel,
ma.ma_code as maCode,
ma.pre_code as preCode,
ma.ma_status as maStatus,
ma.qr_code as qrCode,
ma.buy_price as buyPrice,
ma.ma_vender as maVender,
ma.out_fac_time as outFacTime,
ma.out_fac_code as outFacCode,
ma.assets_code as assetsCode,
ma.check_man as checkMan,
ma.this_check_time as thisCheckTime,
ma.next_check_time as nextCheckTime,
ma.gps_code as gpsCode,
ma.rfid_code as rfidCode,
ma.erp_code as erpCode,
ma.transfer_code as transferCode,
ma.in_out_num as inOutNum,
ma.buy_task as buyTask,
ma.own_house as ownHouse,
ma.company_id as companyId,
ma.create_time as createTime,
ma.update_time as updateTime,
ma.inspect_man as inspectMan,
ma.inspect_status as inspectStatus,
ma.phone as phone,
GROUP_CONCAT( DISTINCT su1.user_id ORDER BY su1.user_id SEPARATOR ',' ) AS keeperId,
GROUP_CONCAT( DISTINCT su1.nick_name ORDER BY su1.user_id SEPARATOR ',' ) AS keeperName,
GROUP_CONCAT( DISTINCT su2.user_id ORDER BY su2.user_id SEPARATOR ',' ) AS repairId,
GROUP_CONCAT( DISTINCT su2.nick_name ORDER BY su2.user_id SEPARATOR ',' ) AS repairName,
baa.asset_name as assetName,
ma.assets_id as assetsId,
ma.remark as remark
FROM
ma_machine ma
LEFT JOIN ma_type mt ON ma.type_id = mt.type_id
and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
and mt4.`level` = '1' and mt4.del_flag = '0'
LEFT JOIN ma_type_keeper mtk on ma.type_id = mtk.type_id
LEFT JOIN sys_user su1 on mtk.user_id = su1.user_id
LEFT JOIN ma_type_repair mtr on ma.type_id = mtr.type_id
LEFT JOIN sys_user su2 on mtr.user_id = su2.user_id
LEFT JOIN bm_asset_attributes baa on ma.assets_id = baa.id
where ma.ma_code = #{maCode}
</select>
<select id="findCodeList" resultType="com.bonus.material.ma.domain.vo.MachineVo">
SELECT
ma.ma_id as maId,
ma.type_id as typeId,
mt4.type_name as itemType,
mt3.type_name as materialType,
mt2.type_name as materialName,
mt.type_name as materialModel,
ma.ma_code as maCode,
ma.pre_code as preCode,
ma.ma_status as maStatus,
ma.qr_code as qrCode,
ma.buy_price as buyPrice,
ma.ma_vender as maVender,
ma.out_fac_time as outFacTime,
ma.out_fac_code as outFacCode,
ma.assets_code as assetsCode,
ma.check_man as checkMan,
ma.this_check_time as thisCheckTime,
ma.next_check_time as nextCheckTime,
ma.gps_code as gpsCode,
ma.rfid_code as rfidCode,
ma.erp_code as erpCode,
ma.transfer_code as transferCode,
ma.in_out_num as inOutNum,
ma.buy_task as buyTask,
ma.own_house as ownHouse,
ma.company_id as companyId,
ma.create_time as createTime,
ma.update_time as updateTime,
ma.inspect_man as inspectMan,
ma.inspect_status as inspectStatus,
ma.phone as phone,
GROUP_CONCAT( DISTINCT su1.user_id ORDER BY su1.user_id SEPARATOR ',' ) AS keeperId,
GROUP_CONCAT( DISTINCT su1.nick_name ORDER BY su1.user_id SEPARATOR ',' ) AS keeperName,
GROUP_CONCAT( DISTINCT su2.user_id ORDER BY su2.user_id SEPARATOR ',' ) AS repairId,
GROUP_CONCAT( DISTINCT su2.nick_name ORDER BY su2.user_id SEPARATOR ',' ) AS repairName,
baa.asset_name as assetName,
ma.assets_id as assetsId,
ma.remark as remark
FROM
ma_machine ma
LEFT JOIN ma_type mt ON ma.type_id = mt.type_id
and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
and mt4.`level` = '1' and mt4.del_flag = '0'
LEFT JOIN ma_type_keeper mtk on ma.type_id = mtk.type_id
LEFT JOIN sys_user su1 on mtk.user_id = su1.user_id
LEFT JOIN ma_type_repair mtr on ma.type_id = mtr.type_id
LEFT JOIN sys_user su2 on mtr.user_id = su2.user_id
LEFT JOIN bm_asset_attributes baa on ma.assets_id = baa.id
where mt2.type_id in(36)
</select>
<insert id="insertInfo">
insert into archives_record_info
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -206,6 +340,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="addOcrRecord">
INSERT into ma_ocr_record(model,code,result,create_by,create_time)
values (#{model},#{code},#{result}, #{createBy}, now())
</insert>
<update id="updateInfo">
update archives_record_info
<trim prefix="SET" suffixOverrides=",">
@ -233,6 +372,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where details_id = #{detailsId}
</update>
<update id="updateStorageData">
UPDATE ma_type
SET storage_num = (IFNULL(storage_num, 0) - #{outNum})
WHERE type_id = #{typeId}
</update>
<update id="updateStorageDataBack">
UPDATE ma_type
SET storage_num = (IFNULL(storage_num, 0) + #{backNum})
WHERE type_id = #{typeId}
</update>
<delete id="deleteInfo">
update archives_record_info
set del_flag = '1'

View File

@ -119,9 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
WHERE
1 = 1 and mm.ma_status = '2' and mm.type_id = #{typeId}
AND mm.ma_id NOT IN (SELECT ma_id from back_check_details WHERE type_id = #{typeId})
AND ba.unit_id = #{unitId}
AND ba.project_id = #{proId}
GROUP BY mm.ma_code
</select>
<select id="selectBackApplyInfoById" resultType="com.bonus.material.back.domain.BackApplyInfo">

View File

@ -233,4 +233,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by
bqi.id limit 1
</select>
<select id="getBoxCodeList" resultType="com.bonus.material.basic.domain.BmQrBoxInfo">
SELECT qb.id as id,
qb.box_id as boxId,
qb.create_by as createBy,
qb.create_time as createTime,
mt1.type_name as typeName,
mt.type_name as typeModelName,
mm.ma_id as maId,
mm.ma_code as maCode,
mm.type_id as maTypeId,
mm.ma_status as maStatus
FROM bm_qrcode_box_bind qb
LEFT JOIN ma_machine mm ON qb.ma_id = mm.ma_id
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0'
LEFT JOIN bm_qrcode_box bqb ON qb.box_id = bqb.box_id
where
mm.ma_status = '5' AND
bqb.box_code = #{boxCode} AND
mt.type_id = #{maTypeId}
</select>
</mapper>

View File

@ -89,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectRepairQuestListByTaskId" resultType="com.bonus.material.scrap.domain.ScrapApplyDetails">
select
sad.id as id,sad.task_id as taskId,sad.parent_id,sad.ma_id as maId,
sad.id as id,sad.task_id as taskId,sad.parent_id as parentId,sad.ma_id as maId,
sad.status as status,
sad.scrap_source,sad.scrap_type,ifnull(sad.scrap_num,0) as scrapNum,
sad.audit_by,sad.audit_remark,sad.audit_time as auditTime,
@ -168,6 +168,66 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="insertRad">
insert into repair_apply_details
(
<if test="newTaskId != null">
task_id,
</if>
<if test="maId != null">
ma_id,
</if>
<if test="typeId != null">
type_id,
</if>
<if test="scrapNum != null">
repair_num,
</if>
status,
<if test="createBy != null and createBy != ''">
create_by,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
<if test="companyId != null">
company_id,
</if>
<if test="backId != null">
back_id,
</if>
create_time
)
values (
<if test="newTaskId != null">
#{newTaskId},
</if>
<if test="maId != null">
#{maId},
</if>
<if test="typeId != null">
#{typeId},
</if>
<if test="scrapNum != null">
#{scrapNum},
</if>
0,
<if test="createBy != null and createBy != ''">
#{createBy},
</if>
<if test="remark != null and remark != ''">
#{remark},
</if>
<if test="companyId != null">
#{companyId},
</if>
<if test="backId != null">
#{backId},
</if>
NOW()
)
</insert>
<update id="updateScrapApplyDetails" parameterType="com.bonus.material.scrap.domain.ScrapApplyDetails">
update scrap_apply_details
<trim prefix="SET" suffixOverrides=",">
@ -202,6 +262,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<update id="updateMaStatus">
update ma_machine
set status = #{status}
where ma_id = #{maId}
</update>
<delete id="deleteScrapApplyDetailsById" parameterType="Long">
delete from scrap_apply_details where id = #{id}
</delete>
@ -239,6 +305,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
group by scrap_type
</select>
<select id="selectBackIdByTaskId" resultType="java.lang.Long">
SELECT
ra.back_id
FROM
scrap_apply_details sad
LEFT JOIN repair_audit_details rad ON sad.parent_id = rad.id
LEFT JOIN repair_apply_details ra ON rad.repair_id = ra.id
WHERE
sad.parent_id = #{parentId}
</select>
</mapper>