Commit 3afd3bdbe2fd37ca4cb102b98d14f2d15d3a8468

Authored by mahuandong
2 parents c022700a 61b46b28

Merge remote-tracking branch 'origin/develop' into develop

src/main/java/com/huaheng/pc/check/checkHeader/mapper/CheckHeaderMapper.java
... ... @@ -4,4 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4 import com.huaheng.pc.check.checkHeader.domain.CheckHeader;
5 5  
6 6 public interface CheckHeaderMapper extends BaseMapper<CheckHeader> {
  7 +
  8 + /**
  9 + * 生成质检单编码
  10 + * @return
  11 + */
  12 + String createCode(String checkType);
7 13 }
8 14 \ No newline at end of file
... ...
src/main/java/com/huaheng/pc/check/checkHeader/service/CheckHeaderService.java
... ... @@ -2,11 +2,34 @@ package com.huaheng.pc.check.checkHeader.service;
2 2  
3 3 import org.springframework.stereotype.Service;
4 4 import javax.annotation.Resource;
5   -import java.util.List;
  5 +import java.text.SimpleDateFormat;
  6 +import java.util.Date;
6 7 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 8 import com.huaheng.pc.check.checkHeader.domain.CheckHeader;
8 9 import com.huaheng.pc.check.checkHeader.mapper.CheckHeaderMapper;
9 10 @Service
10 11 public class CheckHeaderService extends ServiceImpl<CheckHeaderMapper, CheckHeader> {
11 12  
  13 + @Resource
  14 + private CheckHeaderMapper checkHeaderMapper;
  15 +
  16 + //根据单据类型建单据号
  17 + public String createCode(String checkType)
  18 + {
  19 + String code = null;
  20 + Date now = new Date();
  21 + SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
  22 + String maxCode = checkHeaderMapper.createCode(checkType);
  23 + if (maxCode != null && maxCode.length() > 13 && maxCode.substring(maxCode.length() - 13, maxCode.length() - 5).equals(df.format(now)))
  24 + {
  25 + Integer Count = Integer.valueOf(maxCode.substring(maxCode.length() - 5, maxCode.length()));
  26 + code = checkType + df.format(now) + String.format("%05d", Count + 1);
  27 + }
  28 + else
  29 + {
  30 + code = checkType + df.format(now) + "00001";
  31 + }
  32 + return code;
  33 + }
  34 +
12 35 }
... ...
src/main/java/com/huaheng/pc/inventory/inventoryDetail/controller/InventoryDetailController.java
... ... @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 4 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
6 6 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7 +import com.huaheng.common.support.Convert;
7 8 import com.huaheng.common.utils.StringUtils;
8 9 import com.huaheng.common.utils.security.ShiroUtils;
9 10 import com.huaheng.framework.aspectj.lang.annotation.Log;
... ... @@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
24 25 import org.springframework.web.bind.annotation.ResponseBody;
25 26  
26 27 import javax.annotation.Resource;
  28 +import java.lang.reflect.InvocationTargetException;
27 29 import java.util.List;
28 30  
29 31 /**
... ... @@ -106,7 +108,20 @@ public class InventoryDetailController extends BaseController
106 108 return AjaxResult.error("库存明细ID不能为空");
107 109 }
108 110 Integer id = Integer.valueOf(ids);
109   - return inventoryDetailService.detailcreateCheckOutTask(id);
  111 + inventoryDetailService.detailcreateCheckOutTask(id);
  112 + return AjaxResult.success("库存明细出库查看任务下发成功!");
  113 + }
  114 +
  115 +
  116 + /**在库质检*/
  117 + //@RequiresPermissions("inventory:inventoryHeader:detailCheckTask")
  118 + @PostMapping("/detailCheckTask")
  119 + @ResponseBody
  120 + public AjaxResult detailCheckTask(String ids) throws InvocationTargetException, IllegalAccessException {
  121 + if(StringUtils.isEmpty(ids)){
  122 + return AjaxResult.error("库存明细ID不能为空");
  123 + }
  124 + return inventoryDetailService.detailCheckTask(Convert.toIntArray(ids));
110 125 }
111 126  
112 127  
... ...
src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java
... ... @@ -5,15 +5,19 @@ import com.huaheng.framework.web.domain.AjaxResult;
5 5 import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
6 6 import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
7 7  
  8 +import java.lang.reflect.InvocationTargetException;
8 9 import java.util.List;
9 10  
10 11 public interface InventoryDetailService extends IService<InventoryDetail> {
11 12  
12 13  
13   - AjaxResult detailcreateCheckOutTask (Integer id);
  14 + void detailcreateCheckOutTask (Integer id);
14 15  
15 16 List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail);
16 17  
  18 +
  19 + AjaxResult detailCheckTask (Integer[] ids) throws InvocationTargetException, IllegalAccessException;
  20 +
17 21 }
18 22  
19 23  
... ...
src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java
... ... @@ -6,22 +6,36 @@ import com.huaheng.common.exception.service.ServiceException;
6 6 import com.huaheng.common.utils.StringUtils;
7 7 import com.huaheng.common.utils.security.ShiroUtils;
8 8 import com.huaheng.framework.web.domain.AjaxResult;
  9 +import com.huaheng.pc.check.checkDetail.domain.CheckDetail;
  10 +import com.huaheng.pc.check.checkDetail.service.CheckDetailService;
  11 +import com.huaheng.pc.check.checkHeader.domain.CheckHeader;
  12 +import com.huaheng.pc.check.checkHeader.service.CheckHeaderService;
9 13 import com.huaheng.pc.config.location.domain.Location;
10 14 import com.huaheng.pc.config.location.service.LocationService;
11 15 import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
  16 +import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService;
  17 +import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
  18 +import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService;
  19 +import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
12 20 import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
  21 +import com.huaheng.pc.system.dict.domain.DictData;
  22 +import com.huaheng.pc.system.dict.service.DictDataServiceImpl;
  23 +import com.huaheng.pc.system.dict.service.IDictDataService;
13 24 import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
14 25 import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
15 26 import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
16 27 import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
  28 +import org.apache.commons.beanutils.BeanUtils;
  29 +import org.springframework.beans.factory.annotation.Autowired;
17 30 import org.springframework.stereotype.Service;
18 31 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
19 32 import com.huaheng.pc.inventory.inventoryDetail.mapper.InventoryDetailMapper;
  33 +import org.springframework.transaction.annotation.Transactional;
20 34  
21 35 import javax.annotation.Resource;
22   -import java.util.ArrayList;
23   -import java.util.Date;
24   -import java.util.List;
  36 +import java.lang.reflect.InvocationTargetException;
  37 +import java.text.SimpleDateFormat;
  38 +import java.util.*;
25 39  
26 40 @Service
27 41 public class InventoryDetailServiceImpl extends ServiceImpl<InventoryDetailMapper, InventoryDetail> implements InventoryDetailService {
... ... @@ -36,6 +50,16 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
36 50 private InventoryDetailMapper inventoryDetailMapper;
37 51 @Resource
38 52 private LocationService locationService;
  53 + @Autowired
  54 + private InventoryHeaderService inventoryHeaderService;
  55 + @Autowired
  56 + private ReceiptDetailService receiptDetailService;
  57 + @Autowired
  58 + private CheckHeaderService checkHeaderService;
  59 + @Autowired
  60 + private CheckDetailService checkDetailService;
  61 + @Autowired
  62 + private IDictDataService dictDataService;
39 63  
40 64  
41 65  
... ... @@ -43,7 +67,7 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
43 67 * 库存明细出库查看
44 68 * */
45 69 @Override
46   - public AjaxResult detailcreateCheckOutTask(Integer id) {
  70 + public void detailcreateCheckOutTask(Integer id) {
47 71 /*传入库存明细ID,通过该ID找到明细条码确定库位容器,再生成任务*/
48 72  
49 73 InventoryDetail inventoryDetail = inventoryDetailMapper.selectById(id);
... ... @@ -66,10 +90,10 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
66 90 TaskHeader taskHeader = new TaskHeader();
67 91 taskHeader.setWarehouseCode(inventoryDetail.getWarehouseCode());
68 92 taskHeader.setCompanyCode(inventoryDetail.getCompanyCode());
69   - taskHeader.setInternalTaskType(900);
  93 + taskHeader.setInternalTaskType(200);
70 94 taskHeader.setTaskType(900);
71 95 taskHeader.setContainerCode(inventoryDetail.getContainerCode());
72   - taskHeader.setStatus(1);
  96 + taskHeader.setStatus(0);
73 97 taskHeader.setFromLocation(inventoryDetail.getLocationCode());
74 98 taskHeader.setToLocation(inventoryDetail.getLocationCode());
75 99 taskHeader.setCreated(new Date());
... ... @@ -100,7 +124,6 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
100 124 throw new ServiceException("出库查看任务明细生成失败!");
101 125 }
102 126  
103   - return AjaxResult.success("库存明细出库查看任务下发成功!");
104 127 }
105 128  
106 129 @Override
... ... @@ -112,6 +135,103 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
112 135 return inventoryDetailMapper.selectBysql(sql);
113 136 }
114 137  
  138 + //在库质检,把入库主单和子单明细加入到质检单主从中
  139 + @Override
  140 + @Transactional
  141 + public AjaxResult detailCheckTask(Integer[] ids) throws InvocationTargetException, IllegalAccessException {
  142 + HashSet<String> codeSet=new HashSet();
  143 + Integer size=0;
  144 + for(Integer id : ids){
  145 + //查找库存明细,是否为同一个入库单入库的
  146 + InventoryDetail inventoryDetail=this.getById(id);
  147 + if(inventoryDetail==null){
  148 + throw new ServiceException("查不到库存明细");
  149 + }
  150 + if(StringUtils.isEmpty(inventoryDetail.getReceiptCode())){
  151 + throw new ServiceException("查不到库存的入库源头");
  152 + }
  153 +
  154 + //查找未质检的
  155 + if(inventoryDetail.getQcCheck().equals("2")) {
  156 + codeSet.add(inventoryDetail.getReceiptCode());
  157 + }
  158 + }
  159 +
  160 + List<InventoryDetail> inventoryDetails=new ArrayList<>();
  161 + for(String code : codeSet){
  162 + //对库存分类,已入库单划分
  163 + for(Integer id : ids){
  164 + InventoryDetail inventoryDetail=this.getById(id);
  165 + if(inventoryDetail.getReceiptCode().equals(code) && inventoryDetail.getQcCheck().equals("2")){
  166 + inventoryDetails.add(inventoryDetail);
  167 + }
  168 + }
  169 + LambdaQueryWrapper<InventoryDetail> lam=Wrappers.lambdaQuery();
  170 + lam.eq(InventoryDetail::getReceiptCode,code)
  171 + .eq(InventoryDetail::getWarehouseCode,ShiroUtils.getWarehouseCode());
  172 + List<InventoryDetail> inventoryDetailList=this.list(lam);
  173 +
  174 + CheckHeader checkHeader = new CheckHeader();
  175 + //判断入库单明细与该单已选中质检的库存明细比较,得出质检单的类型
  176 + if(inventoryDetailList.size()>inventoryDetails.size()){
  177 + checkHeader.setType("300");
  178 + }else {
  179 + checkHeader.setType("200");
  180 + }
  181 +
  182 + //生成质检单号code
  183 + DictData dictData=new DictData();
  184 + dictData.setWarehouseCode(ShiroUtils.getWarehouseCode());
  185 + dictData.setDictType("checkType");
  186 + dictData.setRemark(checkHeader.getType());
  187 + dictData=dictDataService.selectModel(dictData);
  188 + String checkCode=checkHeaderService.createCode(dictData.getDictValue());
  189 +
  190 + //质检主表插入数据
  191 + checkHeader.setCode(checkCode);
  192 + checkHeader.setWarehouseCode(ShiroUtils.getWarehouseCode());
  193 + checkHeader.setReferCode(code);
  194 + checkHeader.setEnable(1);
  195 + checkHeader.setStatus("0");
  196 + checkHeader.setCreatedBy(ShiroUtils.getLoginName());
  197 + Boolean flag=checkHeaderService.save(checkHeader);
  198 + if(flag == false){
  199 + throw new ServiceException("质检主表插入失败");
  200 + }
  201 +
  202 + List<CheckDetail> checkDetails=new ArrayList<>();
  203 + CheckDetail checkDetail=new CheckDetail();
  204 + //质检明细插入数据
  205 + for(InventoryDetail item : inventoryDetails){
  206 + BeanUtils.copyProperties(checkDetail,item);
  207 + checkDetail.setCheckHeaderId(checkHeader.getId());
  208 + checkDetail.setCheckCode(checkCode);
  209 + checkDetail.setInventoryDetailId(item.getId());
  210 + checkDetail.setStatus("0");
  211 + checkDetail.setCreatedBy(ShiroUtils.getLoginName());
  212 + checkDetail.setCreated(new Date());
  213 + checkDetail.setLastUpdatedBy(null);
  214 + checkDetail.setLastUpdated(new Date());
  215 + checkDetails.add(checkDetail);
  216 + detailcreateCheckOutTask(item.getId());
  217 + item.setQcCheck("1");
  218 + }
  219 + flag=checkDetailService.saveBatch(checkDetails);
  220 + if(flag == false){
  221 + throw new ServiceException("质检子表插入失败");
  222 + }
  223 + if(this.updateBatchById(inventoryDetails) == false){
  224 + throw new ServiceException("库存修改状态失败");
  225 + }
  226 + }
  227 + size=ids.length-inventoryDetails.size();
  228 + if(size == ids.length){
  229 + return AjaxResult.success("所有库存已质检!或无需质检");
  230 + }else {
  231 + return AjaxResult.success("在库质检任务下发成功!有" + size + "条库存明细已质检。");
  232 + }
  233 + }
  234 +
115 235  
116 236 }
117 237  
... ...
src/main/resources/mybatis/check/CheckHeaderMapper.xml
... ... @@ -34,4 +34,9 @@
34 34 closedAt, created, createdBy, lastUpdated, lastUpdatedBy, version, userDef1, userDef2,
35 35 userDef3, userDef4, userDef5, userDef6, userDef7, userDef8, processStamp
36 36 </sql>
  37 +
  38 + <select id="createCode" resultType="java.lang.String">
  39 + SELECT code FROM check_header WHERE substring(code,1,2) = #{checkType,jdbcType=VARCHAR} ORDER BY id DESC LIMIT 1
  40 + </select>
  41 +
37 42 </mapper>
38 43 \ No newline at end of file
... ...
src/main/resources/mybatis/system/DictDataMapper.xml
... ... @@ -181,7 +181,28 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
181 181 </insert>
182 182  
183 183 <select id="selectModel" resultType="com.huaheng.pc.system.dict.domain.DictData">
184   - select * from sys_dict_data where warehouseCode=#{warehouseCode} and dictType=#{dictType} and dictValue=#{dictValue} limit 1
  184 + select * from sys_dict_data
  185 + <where>
  186 + <if test="warehouseCode != null">
  187 + AND warehouseCode = #{warehouseCode}
  188 + </if>
  189 + <if test="headerId != null">
  190 + AND headerId = #{headerId}
  191 + </if>
  192 + <if test="dictValue != null">
  193 + AND dictValue = #{dictValue}
  194 + </if>
  195 + <if test="dictLabel != null">
  196 + AND dictLabel = #{dictLabel}
  197 + </if>
  198 + <if test="dictType != null">
  199 + AND dictType = #{dictType}
  200 + </if>
  201 + <if test="remark != null">
  202 + AND remark = #{remark}
  203 + </if>
  204 + </where>
  205 + limit 1
185 206 </select>
186 207  
187 208 </mapper>
188 209 \ No newline at end of file
... ...
src/main/resources/templates/inventory/inventoryDetail/inventoryDetail.html
... ... @@ -86,6 +86,10 @@
86 86 shiro:hasPermission="inventory:inventory:seeOut">
87 87 <i class="fa fa-eye"></i> 出库查看
88 88 </a>
  89 + <a class="btn btn-outline btn-primary btn-rounded" onclick="check()"
  90 + >
  91 + <i class="fa fa-eye"></i> 在库质检
  92 + </a>
89 93 </div>
90 94 <div class="col-sm-12 select-info">
91 95 <table id="bootstrap-table" data-mobile-responsive="true" class="table table-bordered table-hover"></table>
... ... @@ -338,6 +342,20 @@
338 342 localSubmit(url, "post", "json", data);
339 343 }
340 344  
  345 + //在库质检
  346 + function check() {
  347 + var rows = $("#bootstrap-table").bootstrapTable('getSelections');
  348 + if (rows.length == 0) {
  349 + $.modal.alertWarning("请至少选择一条记录");
  350 + return;
  351 + }
  352 + var url = prefix + "/detailCheckTask";
  353 + var data = {
  354 + "ids": rows[0].id
  355 + };
  356 + localSubmit(url, "post", "json", data);
  357 + }
  358 +
341 359 function localSubmit(url, type, dataType, data) {
342 360 $.modal.loading("正在处理中,请稍后...");
343 361 var config = {
... ...