From a428cf7658d13b6417d9c2351fda3db1a8f12bdc Mon Sep 17 00:00:00 2001 From: bns_han <1604366271@qq.com> Date: Fri, 22 Dec 2023 00:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0-=E9=80=80=E6=96=99=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E4=B8=8E=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BackApplyController.java | 15 +- .../sgzb/material/domain/BackApplyInfo.java | 56 +++++++- .../sgzb/material/mapper/BackApplyMapper.java | 4 +- .../material/service/BackApplyService.java | 2 + .../service/impl/BackApplyServiceImpl.java | 44 +++--- .../mapper/material/BackApplyMapper.xml | 131 +++++++++--------- 6 files changed, 166 insertions(+), 86 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java index 2053b48e..1b5dd242 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java @@ -85,7 +85,7 @@ public class BackApplyController extends BaseController { @Log(title = "领料申请提交", businessType = BusinessType.INSERT) - @PostMapping("submitBackApply") + @PostMapping("/submitBackApply") public AjaxResult submitBackApply(@RequestBody BackApplyInfo bean) { if (StringUtils.isNull(bean)) { return AjaxResult.error("参数错误"); @@ -97,6 +97,8 @@ public class BackApplyController extends BaseController { return AjaxResult.error("后台退料编号生成异常,请重试!"); } bean.setCode(code); + bean.setTaskType(36); + bean.setTaskStatus("37"); // 创建任务 boolean addTaskResult = backApplyService.insertSelective(bean) > 0; if (addTaskResult && bean.getTaskId() != null) { @@ -137,4 +139,15 @@ public class BackApplyController extends BaseController { } } + + + @ApiOperation("退料审核-审核") + @Log(title = "退料审核列表-审核", businessType = BusinessType.UPDATE) + @PostMapping("/audit") + public AjaxResult audit(@RequestBody BackApplyInfo record) + { + return backApplyService.audit(record); + } + + } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/BackApplyInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/BackApplyInfo.java index 35f1a492..8f7c8e21 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/BackApplyInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/BackApplyInfo.java @@ -21,6 +21,10 @@ public class BackApplyInfo extends BaseEntity { @ApiModelProperty(value = "退料ID") private Long id; + /** 退料ID-字符串 */ + @ApiModelProperty(value = "退料ID-字符串") + private String ids; + /** 退料单号 */ @Excel(name = "退料单号") @ApiModelProperty(value = "退料单号") @@ -30,8 +34,11 @@ public class BackApplyInfo extends BaseEntity { @ApiModelProperty(value = "任务ID") private Integer taskId; + /** 任务ID */ + @ApiModelProperty(value = "任务类型") + private Integer taskType; + /** 签订日期 */ - @Excel(name = "签订日期") @ApiModelProperty(value = "签订日期") private String signTime; @@ -41,7 +48,7 @@ public class BackApplyInfo extends BaseEntity { private String backPerson; /** 联系电话 */ - @Excel(name = "联系电话") + @Excel(name = "退料人联系电话") @ApiModelProperty(value = "联系电话") private String phone; @@ -88,21 +95,64 @@ public class BackApplyInfo extends BaseEntity { @ApiModelProperty(value = "工程id") private Integer lotId; + @Excel(name = "退料工程名称") @ApiModelProperty(value = "工程名称") private String lotName; @ApiModelProperty(value = "单位id") private Integer unitId; + @Excel(name = "退料单位名称") @ApiModelProperty(value = "单位名称") private String unitName; + @Excel(name = "退料申请时间") @ApiModelProperty(value = "退料日期") private String backTime; + @Excel(name = "协议号") + @ApiModelProperty(value = "协议编号") + private String agreementCode; + + @Excel(name = "退料状态") + @ApiModelProperty(value = "任务状态") + private String taskStatus; + + @ApiModelProperty(value = "协议id") + private Integer agreementId; + + @ApiModelProperty(value = "类型id") private String typeId; + + @Excel(name = "退料工机具类型") + @ApiModelProperty(value = "类型名称") + private String typeName; + + @ApiModelProperty(value = "规格编号") private String typeCode; + + @ApiModelProperty(value = "数量") private String num; - private String typeByNum; + + @ApiModelProperty(value = "详情id和数量") + private String detailsIdByNum; + + @ApiModelProperty(value = "类型id和数量") + private String typeIdByNum; + + @ApiModelProperty(value = "详情id") + private String detailsId; + + @ApiModelProperty(value = "编码") + private String maCode; + + @ApiModelProperty(value = "在用数量") + private String useNum; + + @ApiModelProperty(value = "操作人") + private String createName; + + @ApiModelProperty(value = "审核人") + private String examineName; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/BackApplyMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/BackApplyMapper.java index b52df25d..0b4591f6 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/BackApplyMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/BackApplyMapper.java @@ -36,7 +36,9 @@ public interface BackApplyMapper { List getView(BackApplyInfo bean); - int setModify(@Param("detailsId") int detailsId, @Param("num") int num); + int setModify(@Param("detailsId") String detailsId, @Param("num") String num); int del(BackApplyInfo bean); + + int audit(BackApplyInfo bean); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/BackApplyService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/BackApplyService.java index 1d357a7a..d82ab697 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/BackApplyService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/BackApplyService.java @@ -35,4 +35,6 @@ public interface BackApplyService { AjaxResult setModify(BackApplyInfo bean); AjaxResult del(BackApplyInfo bean); + + AjaxResult audit(BackApplyInfo record); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java index 2bd024a9..a3cb401a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java @@ -1,15 +1,10 @@ package com.bonus.sgzb.material.service.impl; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.common.core.web.domain.AjaxResult; -import com.bonus.sgzb.material.domain.AgreementInfo; import com.bonus.sgzb.material.domain.BackApplyInfo; import com.bonus.sgzb.material.mapper.BackApplyMapper; -import com.bonus.sgzb.material.service.AgreementInfoService; import com.bonus.sgzb.material.service.BackApplyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -82,21 +77,16 @@ public class BackApplyServiceImpl implements BackApplyService { @Override public AjaxResult setModify(BackApplyInfo bean) { - if (!StringUtils.isEmpty(bean.getTypeByNum())){ - // 使用 parseArray 方法解析 JSON 字符串为 JSONArray 对象 - JSONArray jsonArray = JSON.parseArray(bean.getTypeByNum()); - // 遍历 JSONArray - for (int i = 0; i < jsonArray.size(); i++) { - // 获取当前 JSONObject - JSONObject jsonObject = jsonArray.getJSONObject(i); - // 获取 JSONObject 中的属性值 - int detailsId = jsonObject.getIntValue("detailsId"); - int num = jsonObject.getIntValue("num"); - int res=backApplyMapper.setModify(detailsId,num); - if (res<1){ + if (!StringUtils.isEmpty(bean.getDetailsId()) && !StringUtils.isEmpty(bean.getNum())){ + String[] detailsId = bean.getDetailsId().split(","); + String[] num = bean.getNum().split(","); + for (int i=0;i< detailsId.length;i++){ + String detailsIds=detailsId[i]; + String nums=num[i]; + int re =backApplyMapper.setModify(detailsIds,nums); + if (re<1){ return AjaxResult.error("修改失败"); } - } return AjaxResult.success("修改成功"); }else { @@ -114,4 +104,22 @@ public class BackApplyServiceImpl implements BackApplyService { } } + @Override + public AjaxResult audit(BackApplyInfo bean) { + if (!StringUtils.isEmpty(bean.getIds())){ + String[] ids = bean.getDetailsId().split(","); + for (int i=0;i< ids.length;i++){ + String id=ids[i]; + bean.setId(Long.valueOf(id)); + int re =backApplyMapper.audit(bean); + if (re<1){ + return AjaxResult.error("审核失败"); + } + } + return AjaxResult.success("审核成功"); + }else { + return AjaxResult.error("审核失败,未获取到参数"); + } + } + } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml index 7668f71e..9911c103 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml @@ -26,59 +26,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into tm_task - ( - - task_type, - - - task_status, - - - code, - - - create_by, - - - update_by, - - - update_time, - - - remark, - - - company_id, - + 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}, - + #{taskType}, + #{taskStatus}, + #{code}, + #{createBy}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{companyId}, NOW() + ) @@ -280,24 +248,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" set pre_num =#{num} where id = #{detailsId} + + + UPDATE tm_task tt + LEFT JOIN back_apply_info bai ON bai.task_id = tt.task_id + LEFT JOIN back_apply_details bad on bad.parent_id=bai.id + SET tt.task_status = '38',bad.audit_num=bad.pre_num,bai.direct_audit_by=#{createBy},bai.direct_audit_time=NOW() + WHERE + bai.id = #{id} + DELETE - FROM tm_task_agreement tta LEFT JOIN back_apply_info bai - ON bai.task_id = tta.task_id - WHERE - bai.id = #{id}; + FROM tm_task_agreement + WHERE task_id IN (SELECT task_id FROM back_apply_info WHERE id = #{id}); DELETE - FROM tm_task tt LEFT JOIN back_apply_info bai - ON bai.task_id = tt.task_id - WHERE - bai.id = #{id}; + FROM tm_task + WHERE task_id IN (SELECT task_id FROM back_apply_info WHERE id = #{id}); + DELETE - FROM back_apply_details bad LEFT JOIN back_apply_info bai - ON bai.id = bad.parent_id - WHERE - bai.id = #{id}; + FROM back_apply_details + WHERE parent_id IN (SELECT id FROM back_apply_info WHERE id = #{id}); DELETE FROM back_apply_info @@ -340,6 +312,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bai.back_person like concat('%', #{keyWord}, '%') or and bai.phone like concat('%', #{keyWord}, '%') + + and bui.unit_id = #{unitId} + + + and bpl.lot_id = #{lotId} + + + and tt.task_status = #{taskStatus} + + + and bagi.agreement_code like concat('%', #{agreementCode}, '%') + GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time @@ -368,6 +352,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_machine mm on mm.ma_id = lod.ma_id WHERE tta.agreement_id = #{agreementId} and tt.task_type = '29' + and mt.type_id is not null + + and mt.type_name like concat('%', #{keyWord}, '%') or + and mt3.type_name like concat('%', #{keyWord}, '%') or + and mm.ma_code like concat('%', #{keyWord}, '%') + ) AS subquery1 LEFT JOIN ( @@ -387,6 +377,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id WHERE tta.agreement_id = #{agreementId} and tt.task_type = '36' + and mt.type_id is not null ) AS subquery2 ON subquery1.type_id = subquery2.type_id @@ -408,6 +399,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bagi.agreement_code as agreementCode, bai.back_person as backPerson, bai.phone, + bai.back_time as backTime, + bai.`code`, + bai.remark, + us.user_name as createName, + us2.user_name as examineName, bad.type_id as typeId, mt.type_name typeCode, CONCAT_WS( @@ -428,8 +424,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bagi.project_id LEFT JOIN bm_unit_info bui ON bui.unit_id = bagi.unit_id + LEFT JOIN sys_user us on us.user_id=bai.create_by + LEFT JOIN sys_user us2 on us2.user_id=bai.direct_audit_by WHERE bai.id = #{id} + + and mt.type_name like concat('%', #{keyWord}, '%') or + and mt3.type_name like concat('%', #{keyWord}, '%') or + and mm.ma_code like concat('%', #{keyWord}, '%') + ) AS result1 LEFT JOIN ( @@ -453,6 +456,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE tta.agreement_id = #{agreementId} AND tt.task_type = '29' + and mt.type_id is not null ) AS subquery1 LEFT JOIN (-- 第二个查询作为子查询 SELECT @@ -468,8 +472,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE tta.agreement_id = #{agreementId} AND tt.task_type = '36' + and mt.type_id is not null ) AS subquery2 ON subquery1.type_id = subquery2.type_id - ) AS result2 ON result1.typeId = result2.typeId; + ) AS result2 ON result1.typeId = result2.typeId \ No newline at end of file