diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java new file mode 100644 index 00000000..17c6cfbb --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java @@ -0,0 +1,155 @@ +package com.bonus.sgzb.app.controller; + +import com.bonus.sgzb.app.domain.BackApplyInfo; +import com.bonus.sgzb.app.domain.BmAgreementInfo; +import com.bonus.sgzb.app.service.*; +import com.bonus.sgzb.base.api.domain.TmTask; +import com.bonus.sgzb.common.core.utils.DateUtils; +import com.bonus.sgzb.common.core.utils.StringUtils; +import com.bonus.sgzb.common.core.web.controller.BaseController; +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.common.log.annotation.Log; +import com.bonus.sgzb.common.log.enums.BusinessType; +import io.swagger.annotations.ApiOperation; +import org.aspectj.weaver.loadtime.Aj; +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 javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * 退料接收 + */ +@RestController +@RequestMapping("/backReceive") +public class BackReceiveController extends BaseController { + + @Resource + private BackReceiveService backReceiveService; // 任务表Service + + /** + * 服务对象 + */ + @Resource + private TmTaskService tmTaskService; // 任务表Service + + /** + * 退料接收列表 + * + * @param record 查询条件 + * @return AjaxResult对象 + */ + @Log(title = "退料接收列表", businessType = BusinessType.QUERY) + @PostMapping("getbackReceiveList") + public AjaxResult getbackReceiveList(@RequestBody BackApplyInfo record) { + try { + List list =backReceiveService.getbackReceiveList(record); + return success(list); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + /** + * 退料接收明细 + * + * @param record 查询条件 + * @return AjaxResult对象 + */ + @Log(title = "退料接收明细", businessType = BusinessType.QUERY) + @PostMapping("receiveView") + public AjaxResult receiveView(@RequestBody BackApplyInfo record) { + try { + List list =backReceiveService.receiveView(record); + return success(list); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + /** + * 数量退料--管理方式为1的 + * + * @param record 查询条件 + * @return AjaxResult对象 + */ + @Log(title = "退料接收-数量退料", businessType = BusinessType.INSERT) + @PostMapping("setNumBack") + public AjaxResult setNumBack(@RequestBody BackApplyInfo record) { + try { + int res =backReceiveService.setNumBack(record); + if (res>0){ + return AjaxResult.success("接收成功"); + }else { + return AjaxResult.error("接收失败"); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 数量退料--管理方式为1的 + * + * @param record 查询条件 + * @return AjaxResult对象 + */ + @Log(title = "退料接收-编码退料", businessType = BusinessType.INSERT) + @PostMapping("setCodeBack") + public AjaxResult setCodeBack(@RequestBody BackApplyInfo record) { + try { + int res =backReceiveService.setCodeBack(record); + if (res>0){ + return AjaxResult.success("接收成功"); + }else { + return AjaxResult.error("接收失败"); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Log(title = "退料接收-结束任务", businessType = BusinessType.INSERT) + @PostMapping("endBack") + public AjaxResult endBack(@RequestBody BackApplyInfo record) { + try { + int res =backReceiveService.endBack(record); + if (res>0){ + return AjaxResult.success("接收成功"); + }else { + return AjaxResult.error("接收失败"); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Log(title = "退料接收-编号查询", businessType = BusinessType.INSERT) + @PostMapping("codeQuery") + public AjaxResult codeQuery(@RequestBody BackApplyInfo record) { + try { + List list =backReceiveService.codeQuery(record); + return AjaxResult.success(list); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Log(title = "退料接收-二维码查询", businessType = BusinessType.INSERT) + @PostMapping("qrcodeQuery") + public AjaxResult qrcodeQuery(@RequestBody BackApplyInfo record) { + try { + List list =backReceiveService.qrcodeQuery(record); + return AjaxResult.success(list); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java index ac5b9e51..0d18fee0 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java @@ -138,4 +138,7 @@ public class BackApplyInfo { private BackApplyInfo info; private BackApplyInfo[] arr; + private Integer parentId; + private String sdStatus; + private String qrCode; } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java new file mode 100644 index 00000000..b2f481bd --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java @@ -0,0 +1,60 @@ +package com.bonus.sgzb.app.mapper; + +import com.bonus.sgzb.app.domain.BackApplyInfo; +import com.bonus.sgzb.app.domain.BmAgreementInfo; +import com.bonus.sgzb.base.api.domain.TmTask; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + + +@Mapper +public interface BackReceiveMapper { + + List getbackReceiveList(BackApplyInfo record); + + List receiveView(BackApplyInfo record); + + /** + * 添加退料合格数量 + */ + int setCheckDetails(BackApplyInfo record); + + int insertCheckDetails(BackApplyInfo record); + + int selectTaskNumByMonthWx(@Param("date") Date date, @Param("taskType") Integer taskType); + + int addWxTask(BackApplyInfo bean); + + int addWxTaskAgreement(BackApplyInfo bean); + + int addRepairDetails(BackApplyInfo bean); + + int updateTaskStatus(@Param("taskId") int taskId, @Param("status") int status); + + int updateMaStatus(@Param("maId") int maId,@Param("maStatus") String maStatus); + + List getHgList(BackApplyInfo record); + + int insertIAD(BackApplyInfo bi); + + int updateMT(BackApplyInfo bi); + + List getWxList(BackApplyInfo record); + + int insertTT(BackApplyInfo bean); + + int insertRAD(BackApplyInfo wx); + + int insertTTA(@Param("taskId") int taskId,@Param("agreementId") String agreementId); + + List getBfList(BackApplyInfo record); + + int insertSAD(BackApplyInfo bf); + + List codeQuery(BackApplyInfo record); + + List qrcodeQuery(BackApplyInfo record); +} \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/BackReceiveService.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/BackReceiveService.java new file mode 100644 index 00000000..b949c0b8 --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/BackReceiveService.java @@ -0,0 +1,24 @@ +package com.bonus.sgzb.app.service; + +import com.bonus.sgzb.app.domain.BackApplyInfo; +import com.bonus.sgzb.app.domain.BmAgreementInfo; +import com.bonus.sgzb.base.api.domain.TmTask; + +import java.util.List; + +public interface BackReceiveService { + + List getbackReceiveList(BackApplyInfo record); + + List receiveView(BackApplyInfo record); + + int setNumBack(BackApplyInfo record); + + int setCodeBack(BackApplyInfo record); + + int endBack(BackApplyInfo record); + + List codeQuery(BackApplyInfo record); + + List qrcodeQuery(BackApplyInfo record); +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java new file mode 100644 index 00000000..6f87aee1 --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java @@ -0,0 +1,300 @@ +package com.bonus.sgzb.app.service.impl; + +import com.bonus.sgzb.app.domain.BackApplyInfo; +import com.bonus.sgzb.app.domain.BmAgreementInfo; +import com.bonus.sgzb.app.mapper.BackApplyMapper; +import com.bonus.sgzb.app.mapper.BackReceiveMapper; +import com.bonus.sgzb.app.service.BackApplyService; +import com.bonus.sgzb.app.service.BackReceiveService; +import com.bonus.sgzb.base.api.domain.TmTask; +import com.bonus.sgzb.common.core.utils.DateUtils; +import com.bonus.sgzb.common.core.utils.StringUtils; +import org.apache.poi.util.StringUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + + +@Service +public class BackReceiveServiceImpl implements BackReceiveService { + + @Resource + private BackReceiveMapper backReceiveMapper; + + + @Override + public List getbackReceiveList(BackApplyInfo record) { + return backReceiveMapper.getbackReceiveList(record); + } + + @Override + public List receiveView(BackApplyInfo record) { + return backReceiveMapper.receiveView(record); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int setNumBack(BackApplyInfo record) { + int res =0; + try{ + int taskId = record.getTaskId(); + //修改任务状态 + res= updateTaskStatus(taskId,39); + //插入back_check_details + res = insertBCD(record); + if(res == 0) { + throw new RuntimeException("插入back_check_details异常"); + } + }catch (Exception e){ + throw new RuntimeException(e.getMessage()); + } + + return res; + } + + private int updateTaskStatus(int taskId, int i) { + int res=0; + res=backReceiveMapper.updateTaskStatus(taskId,i); + return res; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int setCodeBack(BackApplyInfo record) { + int res = 0; + try{ + int taskId = record.getTaskId(); + //修改任务状态 + res= updateTaskStatus(taskId,39); + if(res == 0) { + throw new RuntimeException("插入back_check_details异常"); + } + //插入back_check_details + res = insertBCD(record); + if(res == 0) { + throw new RuntimeException("插入back_check_details异常"); + } + }catch (Exception e){ + throw new RuntimeException(e.getMessage()); + } + return res; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int endBack(BackApplyInfo record) { + int res =0; + try{ + int taskId = record.getTaskId(); + //修改任务状态 + res= updateTaskStatus(taskId,40); + if(res == 0) { + throw new RuntimeException("插入back_check_details异常"); + } + //更加退料接收的数据创建下一步流程 + //合格的插入入库记录input_apply_details,修改库存ma_type,修改机具状态 + List hgList = backReceiveMapper.getHgList(record); + if(hgList!=null && hgList.size()>0){ + res = insertIAD(hgList); + if(res == 0) { + throw new RuntimeException("input_apply_details"); + } + res = updateMT(hgList); + if(res == 0) { + throw new RuntimeException("ma_type"); + } + res = updateMaStatus(hgList); + if(res == 0) { + throw new RuntimeException("ma_machines"); + } + } + //维修的创建维修任务,插入任务协议表 + List wxList = backReceiveMapper.getWxList(record); + if(wxList!=null && wxList.size()>0){ + //插入任务表tm_task + int newTaskId = insertTT(hgList,41); + //插入协议任务表tm_task_agreement + res = insertTTA(taskId,wxList); + //插入维修记录表repair_apply_details + res = insertRAD(taskId,wxList); + } + //待报废的创建报废任务,插入任务协议表 + + List bfList = backReceiveMapper.getBfList(record); + if(wxList!=null && wxList.size()>0){ + //插入任务表tm_task + int newTaskId = insertTT(hgList,57); + //插入协议任务表tm_task_agreement + res = insertTTA(taskId,hgList); + //插入维修记录表scrap_apply_details + res = insertSAD(taskId,hgList); + } + + + + }catch (Exception e){ + throw new RuntimeException(e.getMessage()); + } + + return 0; + } + + @Override + public List codeQuery(BackApplyInfo record) { + + return backReceiveMapper.codeQuery(record); + } + + @Override + public List qrcodeQuery(BackApplyInfo record) { + return backReceiveMapper.qrcodeQuery(record); + } + + private int insertRAD(int taskId, List wxList) { + + int result = 0; + if(wxList !=null){ + for( BackApplyInfo wx : wxList ){ + wx.setTaskId(taskId); + result = backReceiveMapper.insertRAD(wx); + } + + } + return result; + } + + private int insertSAD(int taskId, List list) { + int result = 0; + if(list !=null){ + for( BackApplyInfo bf : list ){ + bf.setTaskId(taskId); + result = backReceiveMapper.insertSAD(bf); + } + + } + return result; + } + + private int insertTTA(int taskId, List list) { + int res = 0 ; + String agreementId = list.get(0).getAgreementId(); + res = backReceiveMapper.insertTTA(taskId,agreementId); + return res; + } + + private int insertTT(List hgList, int taskType) { + int newTask = 0; + + //生成单号 + String code = genCodeRule(taskType); + + BackApplyInfo applyInfo = new BackApplyInfo(); + applyInfo.setTaskType(taskType); + String taskStatus=""; + if(41 == taskType){ + taskStatus = "42"; + } + if(57 == taskType){ + taskStatus = "58"; + } + applyInfo.setTaskStatus(taskStatus); + applyInfo.setCode(code); + //创建人 + newTask = backReceiveMapper.insertTT(applyInfo); + return newTask; + } + + + private int updateMaStatus(List hgList) { + int res =0; + if(hgList!=null && hgList.size()>0){ + for(BackApplyInfo bi : hgList){ + Integer maId = bi.getMaId(); + if(maId == null){ + + }else{ + res = backReceiveMapper.updateMaStatus(maId,"15"); + } + + } + } + return res; + } + + private int updateMT(List hgList) { + int res =0; + if(hgList!=null && hgList.size()>0){ + for(BackApplyInfo bi : hgList){ + res = backReceiveMapper.updateMT(bi); + } + } + return res; + } + + private int insertIAD(List hgList) { + int res =0; + if(hgList!=null && hgList.size()>0){ + for(BackApplyInfo bi : hgList){ + res = backReceiveMapper.insertIAD(bi); + } + } + return res; + } + + private int insertBCD(BackApplyInfo record) { + int res =0; + BackApplyInfo[] arr = record.getArr(); + if(arr.length>0){ + for(int i=0 ; i< arr.length;i++){ + res = backReceiveMapper.insertCheckDetails(arr[i]); + String manageType = arr[i].getManageType(); + if("0".equals(manageType)){ + String backStatus = arr[i].getBackStatus(); + int maId = arr[i].getMaId(); + if("1".equals(backStatus)){ + //退料合格状态变为退料带入库84 + backReceiveMapper.updateMaStatus(maId,"84"); + } + if("2".equals(backStatus)){ + //退料维修状态变为退料待检修17 + backReceiveMapper.updateMaStatus(maId,"17"); + } + if("3".equals(backStatus)){ + //退料待报废状态变为退料待报废20 + backReceiveMapper.updateMaStatus(maId,"20"); + } + } + } + } + + return res; + } + + + // 编号生成规则 + private String genCodeRule(int taskType) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + Date nowDate = DateUtils.getNowDate(); + String format = dateFormat.format(nowDate); + int taskNum = backReceiveMapper.selectTaskNumByMonthWx(nowDate,taskType) + 1; + String code=""; + if(41 == taskType){ + code = "WX"; + } + if(57 == taskType){ + code = "BF"; + } + if (taskNum>9 && taskNum<100){ + code = code + format + "-00" + taskNum; + }else if (taskNum>99 && taskNum<1000){ + code = code +format + "-0" + taskNum; + }else { + code = code + format + "-000" + taskNum; + } + return code; + } +} diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml new file mode 100644 index 00000000..7c15c3b1 --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -0,0 +1,809 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into tm_task + ( + + task_type, + + + task_status, + + + code, + + + create_by, + + + update_by, + + + update_time, + + + remark, + + + company_id, + + create_time + ) values ( + + #{taskType}, + + + #{taskStatus}, + + + #{code}, + + + #{createBy}, + + + #{updateBy}, + + + #{updateTime}, + + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into tm_task + ( + + task_type, + + + task_status, + + + code, + + + create_by, + + + update_by, + + + update_time, + + + remark, + + + company_id, + + create_time + ) values ( + + #{taskType}, + + + #{taskStatus}, + + + #{code}, + + + #{createBy}, + + + #{updateBy}, + + + #{updateTime}, + + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into tm_task_agreement + ( + + task_id, + + + agreement_id, + + + create_by, + + + update_by, + + + update_time, + + + remark, + + + company_id, + + create_time + ) values ( + + #{taskId}, + + + #{agreementId}, + + + #{createBy}, + + + #{updateBy}, + + + #{updateTime}, + + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into tm_task_agreement + ( + + task_id, + + + agreement_id, + + create_time + ) values ( + + #{taskId}, + + + #{agreementId}, + + NOW() + ) + + + + insert into repair_apply_details + ( + + task_id, + + + ma_id, + + + type_id, + + + repair_num, + + + repaired_num, + + + scrap_num, + + + status, + + + create_by, + + + update_by, + + update_time, + + remark, + + + company_id, + + + back_id, + + + repairer, + + create_time + ) + values ( + + #{taskId}, + + + #{maId}, + + + #{typeId}, + + + #{repairNum}, + + + #{repairedNum}, + + + #{scrapNum}, + + + #{scrapNum}, + + + #{createBy}, + + + #{createBy}, + + NOW(), + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into repair_apply_details + ( + + task_id, + + + ma_id, + + + type_id, + + + repair_num, + + + repaired_num, + + + scrap_num, + + + status, + + + create_by, + + + update_by, + + update_time, + + remark, + + + company_id, + + + back_id, + + + repairer, + + create_time + ) + values ( + + #{taskId}, + + + #{maId}, + + + #{typeId}, + + + #{backNum}, + + + #{repairedNum}, + + + #{scrapNum}, + + + #{scrapNum}, + + + #{createBy}, + + + #{createBy}, + + NOW(), + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into back_check_details + ( + + parent_id, + + + type_id, + + + ma_id, + + + back_num, + + + back_status, + + + create_by, + + + update_by, + + update_time, + + remark, + + + company_id, + + create_time + ) + values ( + + #{id}, + + + #{typeId}, + + + #{maId}, + + + #{backNum}, + + + #{backStatus}, + + + #{createBy}, + + + #{createBy}, + + NOW(), + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into input_apply_details + ( + + task_id, + + + ma_id, + + + type_id, + + + parent_id, + + + input_num, + + input_type, + + create_by, + + + update_by, + + update_time, + + remark, + + + company_id, + + create_time + ) + values ( + + #{taskId}, + + + #{maId}, + + + #{typeId}, + + + #{parentId}, + + + #{inputNum}, + + '2', + + #{createBy}, + + + #{createBy}, + + NOW(), + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into input_apply_details + ( + + task_id, + + + ma_id, + + + type_id, + + + parent_id, + + + input_num, + + input_type, + + create_by, + + + update_by, + + update_time, + + remark, + + + company_id, + + create_time + ) + values ( + + #{taskId}, + + + #{maId}, + + + #{typeId}, + + + #{parentId}, + + + #{backNum}, + + '2', + + #{createBy}, + + + #{createBy}, + + NOW(), + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into scrap_apply_details + ( + + task_id, + + + parent_id, + + + ma_id, + + + type_id, + + + scrap_num, + + scrap_source, + status, + + create_by, + + + company_id, + + create_time + ) + values ( + + #{taskId}, + + + #{parentId}, + + + #{maId}, + + + #{typeId}, + + + #{backNum}, + + '1', + '0', + + #{createBy}, + + + #{companyId}, + + NOW() + ) + + + + + update tm_task + set task_status=#{status} + where task_id = #{taskId} + + + update ma_machine + set ma_status=#{maStatus} + where ma_id = #{maId} + + + + UPDATE ma_type + SET num = (IFNULL(num, 0)) + #{backNum} + WHERE type_id = #{typeId} + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml index b29c512e..9045ae7b 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml @@ -90,7 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join ma_type mt1 on mt.parent_id = mt1.type_id left join ma_type mt2 on mt1.parent_id = mt2.type_id left join ma_label_bind mmb on m.ma_id = mmb.ma_id and m.type_id = mmb.type_id - where m.ma_code = #{maCode} + where m.ma_code = #{maCode} or m.qr_code = #{maCode}