Commit cad4b16b5b00bf3b947bf13c371da778a9509617

Authored by pengcheng
1 parent cdd268f1

出库时出库配置添加

src/main/java/com/huaheng/pc/inventory/inventoryDetail/mapper/InventoryDetailMapper.java
... ... @@ -3,5 +3,10 @@ package com.huaheng.pc.inventory.inventoryDetail.mapper;
3 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4 import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
5 5  
  6 +import java.util.List;
  7 +
6 8 public interface InventoryDetailMapper extends BaseMapper<InventoryDetail> {
  9 +
  10 + List<InventoryDetail> selectBysql(String sql);
  11 +
7 12 }
8 13 \ No newline at end of file
... ...
src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java
... ... @@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
4 4 import com.huaheng.framework.web.domain.AjaxResult;
5 5 import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
6 6  
  7 +import java.util.List;
  8 +
7 9 public interface InventoryDetailService extends IService<InventoryDetail> {
8 10  
9 11  
10 12 AjaxResult detailcreateCheckOutTask (Integer id);
11 13  
  14 + List<InventoryDetail> selectBysql(String sql);
  15 +
12 16 }
13 17  
14 18  
... ...
src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java
... ... @@ -102,6 +102,10 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
102 102 return AjaxResult.success("库存明细出库查看任务下发成功!");
103 103 }
104 104  
  105 + @Override
  106 + public List<InventoryDetail> selectBysql(String sql) {
  107 + return inventoryDetailMapper.selectBysql(sql);
  108 + }
105 109  
106 110  
107 111 }
... ...
src/main/java/com/huaheng/pc/shipment/shipmentDetail/controller/ShipmentDetailController.java
... ... @@ -67,6 +67,7 @@ public class ShipmentDetailController extends BaseController
67 67 .eq(ShipmentDetail::getWarehouseCode,ShiroUtils.getWarehouseCode())
68 68 .in(ShipmentDetail::getCompanyCode,ShiroUtils.getCompanyCodeList())
69 69 .eq(StringUtils.isNotEmpty(shipmentDetail.getShipmentCode()),ShipmentDetail::getShipmentCode,shipmentDetail.getShipmentCode())
  70 + .eq(ShipmentDetail::getShipmentId,shipmentDetail.getShipmentId())
70 71 .orderByAsc(ShipmentDetail::getId);
71 72  
72 73 if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){
... ...
src/main/java/com/huaheng/pc/shipment/shippingCombination/controller/ShippingCombinationController.java
... ... @@ -8,11 +8,14 @@ import com.huaheng.common.utils.security.ShiroUtils;
8 8 import com.huaheng.framework.web.controller.BaseController;
9 9 import com.huaheng.framework.web.domain.AjaxResult;
10 10 import com.huaheng.framework.web.page.TableDataInfo;
  11 +import com.huaheng.pc.config.FilterConfigDetail.domain.FilterConfigDetail;
  12 +import com.huaheng.pc.config.FilterConfigDetail.service.FilterConfigDetailService;
11 13 import com.huaheng.pc.config.configValue.domain.ConfigValue;
12 14 import com.huaheng.pc.config.configValue.service.ConfigValueService;
13 15 import com.huaheng.pc.config.material.domain.Material;
14 16 import com.huaheng.pc.config.material.service.MaterialServiceImpl;
15 17 import com.huaheng.pc.config.shipmentPreference.domain.ShipmentPreference;
  18 +import com.huaheng.pc.config.shipmentPreference.service.ShipmentPreferenceService;
16 19 import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
17 20 import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
18 21 import com.huaheng.pc.shipment.shipmentContainerDetail.service.ShipmentContainerDetailService;
... ... @@ -30,6 +33,7 @@ import org.springframework.stereotype.Controller;
30 33 import org.springframework.ui.ModelMap;
31 34 import org.springframework.web.bind.annotation.*;
32 35  
  36 +import java.util.ArrayList;
33 37 import java.util.List;
34 38  
35 39 @Controller
... ... @@ -54,6 +58,10 @@ public class ShippingCombinationController extends BaseController {
54 58 InventoryDetailService inventoryDetailService;
55 59 @Autowired
56 60 ConfigValueService configValueService;
  61 + @Autowired
  62 + FilterConfigDetailService filterConfigDetailService;
  63 + @Autowired
  64 + ShipmentPreferenceService shipmentPreferenceService;
57 65  
58 66  
59 67 /**
... ... @@ -89,38 +97,6 @@ public class ShippingCombinationController extends BaseController {
89 97 }
90 98  
91 99  
92   - /**
93   - * 获取能出库的库存列表
94   - * @param code,id
95   - * @return
96   - */
97   - @PostMapping("/getInventory")
98   - @ResponseBody
99   - public TableDataInfo getInventory(String code, Integer id){
100   - //找到主单的账套
101   - LambdaQueryWrapper<ShipmentHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
102   - lambdaQueryWrapper.eq(ShipmentHeader::getCode,code)
103   - .eq(ShipmentHeader::getWarehouseCode,ShiroUtils.getWarehouseCode());
104   - ShipmentHeader shipmentHeader=shipmentHeaderService.getOne(lambdaQueryWrapper);
105   - if(shipmentHeader==null){
106   - throw new ServiceException("找不到主单");
107   - }
108   - //找到子单物料
109   - ShipmentDetail shipmentDetail=new ShipmentDetail();
110   - shipmentDetail=shipmentDetailService.getById(id);
111   - if(shipmentDetail==null){
112   - throw new ServiceException("找不到子单");
113   - }
114   - LambdaQueryWrapper<InventoryDetail> lam = Wrappers.lambdaQuery();
115   - lam.eq(InventoryDetail::getWarehouseCode,shipmentHeader.getWarehouseCode())
116   - .eq(InventoryDetail::getCompanyCode,shipmentHeader.getCompanyCode())
117   - .eq(InventoryDetail::getMaterialCode,shipmentDetail.getMaterialCode());
118   -
119   - List<InventoryDetail> list= inventoryDetailService.list(lam);
120   - return getDataTable(list);
121   - }
122   -
123   -
124 100 // /**
125 101 // * 获取能出库的库存列表
126 102 // * @param code,id
... ... @@ -143,42 +119,10 @@ public class ShippingCombinationController extends BaseController {
143 119 // if(shipmentDetail==null){
144 120 // throw new ServiceException("找不到子单");
145 121 // }
146   -//
147   -// //出库首选项
148   -// LambdaQueryWrapper<ShipmentPreference> shipmentPreferenceLambdaQueryWrapper=Wrappers.lambdaQuery();
149   -//
150   -// //出库规则
151   -// //出库子单的分配规则
152   -// if(StringUtils.isNotEmpty(shipmentDetail.getAllocationRule())){
153   -//
154   -//
155   -// }
156   -//
157   -// //物料的分+配规则
158   -// LambdaQueryWrapper<Material> materialLambdaQueryWrapper=Wrappers.lambdaQuery();
159   -// materialLambdaQueryWrapper.eq(Material::getCode,shipmentDetail.getMaterialCode())
160   -// .eq(Material::getWarehouseCode,shipmentDetail.getWarehouseCode());
161   -// Material material=materialService.getOne(materialLambdaQueryWrapper);
162   -// if(StringUtils.isNotEmpty(material.getAllocationRule())){
163   -//
164   -//
165   -// }
166   -//
167   -// //仓库的分配规则
168   -// LambdaQueryWrapper<ConfigValue> configValueLambdaQueryWrapper=Wrappers.lambdaQuery();
169   -// configValueLambdaQueryWrapper.eq(ConfigValue::getModuleType,"shipment")
170   -// .eq(ConfigValue::getWarehouseCode,shipmentDetail.getWarehouseCode());
171   -// ConfigValue configValue=configValueService.getOne(configValueLambdaQueryWrapper);
172   -// //查找出库首选项
173   -//
174   -// configValue.getIdentifier();
175   -//
176   -//
177   -//
178 122 // LambdaQueryWrapper<InventoryDetail> lam = Wrappers.lambdaQuery();
179 123 // lam.eq(InventoryDetail::getWarehouseCode,shipmentHeader.getWarehouseCode())
180 124 // .eq(InventoryDetail::getCompanyCode,shipmentHeader.getCompanyCode())
181   -// .eq(InventoryDetail::getMaterialName,shipmentDetail.getMaterialCode());
  125 +// .eq(InventoryDetail::getMaterialCode,shipmentDetail.getMaterialCode());
182 126 //
183 127 // List<InventoryDetail> list= inventoryDetailService.list(lam);
184 128 // return getDataTable(list);
... ... @@ -186,6 +130,99 @@ public class ShippingCombinationController extends BaseController {
186 130  
187 131  
188 132 /**
  133 + * 获取能出库的库存列表
  134 + * @param code,id
  135 + * @return
  136 + */
  137 + @PostMapping("/getInventory")
  138 + @ResponseBody
  139 + public TableDataInfo getInventory(String code, Integer id){
  140 + //找到主单
  141 + LambdaQueryWrapper<ShipmentHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
  142 + lambdaQueryWrapper.eq(ShipmentHeader::getCode,code)
  143 + .eq(ShipmentHeader::getWarehouseCode,ShiroUtils.getWarehouseCode());
  144 + ShipmentHeader shipmentHeader=shipmentHeaderService.getOne(lambdaQueryWrapper);
  145 + if(shipmentHeader==null){
  146 + throw new ServiceException("找不到主单");
  147 + }
  148 + //找到子单
  149 + ShipmentDetail shipmentDetail=new ShipmentDetail();
  150 + shipmentDetail=shipmentDetailService.getById(id);
  151 + if(shipmentDetail==null){
  152 + throw new ServiceException("找不到子单");
  153 + }
  154 +
  155 + //查找分配规则
  156 + List<InventoryDetail> list=new ArrayList<>();
  157 + FilterConfigDetail filterConfigDetail=new FilterConfigDetail();
  158 + LambdaQueryWrapper<FilterConfigDetail> filterConfigDetailLambdaQueryWrapper=Wrappers.lambdaQuery();
  159 + filterConfigDetailLambdaQueryWrapper.eq(FilterConfigDetail::getWarehouseCode,shipmentDetail.getWarehouseCode());
  160 +
  161 + //出库子单的分配规则有时,优先出库子单的分配规则
  162 + if(StringUtils.isNotEmpty(shipmentDetail.getAllocationRule())){
  163 + filterConfigDetailLambdaQueryWrapper.eq(FilterConfigDetail::getCode,shipmentDetail.getAllocationRule());
  164 + filterConfigDetail=filterConfigDetailService.getOne(filterConfigDetailLambdaQueryWrapper);
  165 + if(filterConfigDetail==null){
  166 + throw new ServiceException("出库子单出库规则配置不存在");
  167 + }
  168 +
  169 + //根据sql查库存
  170 + try {
  171 + list = inventoryDetailService.selectBysql(filterConfigDetail.getStatement());
  172 + }catch (Exception e){
  173 + throw new ServiceException("sql错误");
  174 + }
  175 + return getDataTable(list);
  176 + }
  177 +
  178 + //出库子单的分配规则没有时,优先物料的分配规则
  179 + LambdaQueryWrapper<Material> materialLambdaQueryWrapper=Wrappers.lambdaQuery();
  180 + materialLambdaQueryWrapper.eq(Material::getCode,shipmentDetail.getMaterialCode())
  181 + .eq(Material::getWarehouseCode,shipmentDetail.getWarehouseCode());
  182 + Material material=materialService.getOne(materialLambdaQueryWrapper);
  183 + if(StringUtils.isNotEmpty(material.getAllocationRule())){
  184 + filterConfigDetailLambdaQueryWrapper.eq(FilterConfigDetail::getCode,material.getAllocationRule());
  185 + filterConfigDetail=filterConfigDetailService.getOne(filterConfigDetailLambdaQueryWrapper);
  186 + if(filterConfigDetail==null){
  187 + throw new ServiceException("物料出库规则配置不存在");
  188 + }
  189 +
  190 + //根据sql查库存
  191 + list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement());
  192 + return getDataTable(list);
  193 + }
  194 +
  195 + //都没有时,默认仓库的分配规则
  196 + LambdaQueryWrapper<ConfigValue> configValueLambdaQueryWrapper=Wrappers.lambdaQuery();
  197 + configValueLambdaQueryWrapper.eq(ConfigValue::getModuleType,"shipment")
  198 + .eq(ConfigValue::getWarehouseCode,shipmentDetail.getWarehouseCode());
  199 + ConfigValue configValue=configValueService.getOne(configValueLambdaQueryWrapper);
  200 + if(configValue==null){
  201 + throw new ServiceException("仓库的出库配置不存在");
  202 + }
  203 +
  204 + //查找出库首选项
  205 + LambdaQueryWrapper<ShipmentPreference> slam=Wrappers.lambdaQuery();
  206 + slam.eq(ShipmentPreference::getCode,configValue.getIdentifier())
  207 + .eq(ShipmentPreference::getWarehouseCode,configValue.getWarehouseCode());
  208 + ShipmentPreference shipmentPreference=shipmentPreferenceService.getOne(slam);
  209 + if(shipmentPreference==null){
  210 + throw new ServiceException("仓库的出库配置中出库首选项不存在");
  211 + }
  212 + //查找分配规则
  213 + filterConfigDetailLambdaQueryWrapper.eq(FilterConfigDetail::getCode,shipmentPreference.getAllocationRule());
  214 + filterConfigDetail=filterConfigDetailService.getOne(filterConfigDetailLambdaQueryWrapper);
  215 + if(filterConfigDetail==null){
  216 + throw new ServiceException("出库首选项中出库规则配置不存在");
  217 + }
  218 +
  219 + //根据sql查库存
  220 + list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement());
  221 + return getDataTable(list);
  222 + }
  223 +
  224 +
  225 + /**
189 226 * 保存组盘
190 227 * @param shipmentCombinationModel
191 228 * @return
... ...
src/main/resources/mybatis/inventory/InventoryDetailMapper.xml
... ... @@ -54,4 +54,9 @@
54 54 lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy, userDef1, userDef2,
55 55 userDef3, processStamp, receiptCode, receiptDetailId
56 56 </sql>
  57 +
  58 +
  59 + <select id="selectBysql" parameterType="String" resultType="com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail">
  60 + ${value}
  61 + </select>
57 62 </mapper>
58 63 \ No newline at end of file
... ...
src/main/resources/templates/shipment/shipmentDetail/add.html
... ... @@ -34,9 +34,9 @@
34 34 <div class="form-group">
35 35 <label class="col-sm-3 control-label">分配规则:</label>
36 36 <div class="col-sm-8">
37   - <select id="allocationRule" class="form-control" th:with="allocationRule=${@filterConfigDetail.list()}">
  37 + <select id="allocationRule" class="form-control" th:with="allocationRule=${@FilterConfigDetailService.list()}">
38 38 <option value=" " checked></option>
39   - <option th:each="allocationRules:${allocationRule}" th:text="${allocationRules['code']}" th:value="${allocationRules['description']}"></option>
  39 + <option th:each="allocationRules:${allocationRule}" th:text="${allocationRules['description']}" th:value="${allocationRules['code']}"></option>
40 40 </select>
41 41 </div>
42 42 </div>
... ... @@ -102,12 +102,6 @@
102 102 <input id="shipQty" name="shipQty" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')">
103 103 </div>
104 104 </div>
105   - <div class="form-group">
106   - <label class="col-sm-3 control-label">物料单价:</label>
107   - <div class="col-sm-8">
108   - <input id="price" name="price" class="form-control" type="text">
109   - </div>
110   - </div>
111 105 <div class="form-group">
112 106 <div class="form-control-static col-sm-offset-9">
113 107 <button type="submit" class="btn btn-primary">提交</button>
... ... @@ -160,6 +154,7 @@
160 154 "batch": $("input[name='batch']").val(),
161 155 "lot": $("input[name='lot']").val(),
162 156 "projectNo": $("input[name='project']").val(),
  157 + "allocationRule": $("#allocationRule option:selected").val(),
163 158 "manufactureDate": $("input[name='manufactureDate']").val(),
164 159 "expirationDate": $("input[name='expirationDate']").val(),
165 160 "agingDate": $("input[name='agingDate']").val(),
... ...
src/main/resources/templates/shipment/shipmentDetail/edit.html
... ... @@ -19,12 +19,6 @@
19 19 </div>
20 20 </div>
21 21 <div class="form-group">
22   - <label class="col-sm-3 control-label">上游系统行号:</label>
23   - <div class="col-sm-8">
24   - <input id="sourceLine" name="sourceLine" th:field="*{sourceLine}" class="form-control" type="text" readonly="readonly">
25   - </div>
26   - </div>
27   - <div class="form-group">
28 22 <label class="col-sm-3 control-label">存货编码:</label>
29 23 <div class="col-sm-8">
30 24 <input id="materialCode" name="materialCode" th:field="*{materialCode}" class="form-control" type="text" readonly="readonly">
... ... @@ -51,7 +45,16 @@
51 45 <div class="form-group">
52 46 <label class="col-sm-3 control-label">项目号:</label>
53 47 <div class="col-sm-8">
54   - <input id="project" name="project" th:field="*{project}" class="form-control" type="text">
  48 + <input id="project" name="projectNo" th:field="*{projectNo}" class="form-control" type="text">
  49 + </div>
  50 + </div>
  51 + <div class="form-group">
  52 + <label class="col-sm-3 control-label">分配规则:</label>
  53 + <div class="col-sm-8">
  54 + <select id="allocationRule" class="form-control" th:with="allocationRule=${@FilterConfigDetailService.list()}" th:field="*{allocationRule}">
  55 + <option value=" " checked></option>
  56 + <option th:each="allocationRules:${allocationRule}" th:text="${allocationRules['description']}" th:value="${allocationRules['code']}"></option>
  57 + </select>
55 58 </div>
56 59 </div>
57 60 <div class="form-group">
... ... @@ -75,27 +78,21 @@
75 78 <div class="form-group">
76 79 <label class="col-sm-3 control-label">库存状态:</label>
77 80 <div class="col-sm-8">
78   - <select id="inventoryStatus" class="form-control" th:with="inventoryStatus=${@dict.getType('inventoryStatus')}" th:field="*{inventoryStatus}">
  81 + <select id="inventoryStatus" class="form-control" th:with="inventoryStatus=${@dict.getType('inventoryStatus')}" th:field="*{inventorySts}">
79 82 <option th:each="dict : ${inventoryStatus}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option>
80 83 </select>
81 84 </div>
82 85 </div>
83   - <div class="form-group">
  86 + <div class="form-group">
84 87 <label class="col-sm-3 control-label">发货数量:</label>
85 88 <div class="col-sm-8">
86   - <input id="qty" name="qty" th:field="*{qty}" class="form-control" type="text">
  89 + <input id="qty" name="shipQty" th:field="*{shipQty}" class="form-control" type="text">
87 90 </div>
88 91 </div>
89 92 <div class="form-group">
90 93 <label class="col-sm-3 control-label">已出数量:</label>
91 94 <div class="col-sm-8">
92   - <input id="qtyCompleted" name="qtyCompleted" th:field="*{qtyCompleted}" class="form-control" type="text" readonly="readonly">
93   - </div>
94   - </div>
95   - <div class="form-group">
96   - <label class="col-sm-3 control-label">物料单价:</label>
97   - <div class="col-sm-8">
98   - <input id="price" name="price" th:field="*{price}" class="form-control" type="number">
  95 + <input id="requestQty" name="requestQty" th:field="*{requestQty}" class="form-control" type="text" readonly="readonly">
99 96 </div>
100 97 </div>
101 98 <div class="form-group">
... ... @@ -187,18 +184,15 @@
187 184 "id":$("#id").val(),
188 185 "shipmentId": $("input[name='shipmentId']").val(),
189 186 "shipmentCode": $("input[name='shipmentCode']").val(),
190   - "sourceLine": $("input[name='sourceLine']").val(),
191   - "materialId": $("input[name='materialId']").val(),
192 187 "materialCode": $("input[name='materialCode']").val(),
193 188 "batch": $("input[name='batch']").val(),
194 189 "lot": $("input[name='lot']").val(),
195   - "project": $("input[name='project']").val(),
  190 + "projectNo": $("input[name='projectNo']").val(),
  191 + "allocationRule": $("#allocationRule option:selected").val(),
196 192 "manufactureDate": $("input[name='manufactureDate']").val(),
197 193 "expirationDate": $("input[name='expirationDate']").val(),
198   - "agingDate": $("input[name='agingDate']").val(),
199   - "inventoryStatus": $("#inventoryStatus option:selected").val(),
200   - "qty": $("input[name='qty']").val(),
201   - "price": $("input[name='price']").val(),
  194 + "inventorySts": $("#inventoryStatus option:selected").val(),
  195 + "shipQty": $("input[name='shipQty']").val(),
202 196 "userDef1": $("input[name='userDef1']").val(),
203 197 "userDef2": $("input[name='userDef2']").val(),
204 198 "userDef3": $("input[name='userDef3']").val(),
... ...