Browse Source

修改库存查询页面的库存处理页面

lwx_dev
erdanergou 3 years ago
parent
commit
c7a033fb28
  1. 57
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 8
      src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.java
  3. 12
      src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml
  4. 10
      src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationModel.java
  5. 9
      src/main/java/com/dreamchaser/depository_manage/service/PlaceService.java
  6. 14
      src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java
  7. 39
      src/main/resources/templates/pages/application/application_multi.html
  8. 2
      src/main/resources/templates/pages/depository/table-stock.html
  9. 12
      target/classes/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml
  10. 39
      target/classes/templates/pages/application/application_multi.html
  11. 2
      target/classes/templates/pages/depository/table-stock.html

57
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -867,10 +867,13 @@ public class DepositoryRecordController {
public RestResponse applicantMultiCreate(@RequestParam Map<String, Object> map, HttpServletRequest request) {
Integer page = ObjectFormatUtil.toInteger(map.get("page"));
Integer pagesize = ObjectFormatUtil.toInteger(map.get("size"));
Integer start = (page - 1) * pagesize;
int start = (page - 1) * pagesize;
Integer end = page * 10;
UserByPort userToken = (UserByPort) request.getAttribute("userToken");
Long size = redisTemplateForHash.boundListOps("mids" + userToken.getId()).size();
if(size == null){
size = 0L;
}
if (end > size) {
end = ObjectFormatUtil.toInteger(size);
}
@ -892,16 +895,17 @@ public class DepositoryRecordController {
ap.setDepositoryName(depositoryRecordById.getDname());
ap.setMid(materialById.getMid());
ap.setIid(materialById.getId());
ap.setPlaceCode(placeCode);
ap.setVersion(materialById.getVersion());
ap.setMname(materialById.getMname());
ap.setCode(materialById.getCode());
ap.setPrice(materialById.getPrice());
ap.setApplicant(userToken.getId());
ap.setQuantity(1.0);
ap.setUnit(materialById.getUnit());
ap.setUnit("-1");
ap.setShowUnit(materialById.getUnit());
String[] placeCodes = placeCode.split(" ");
ap.setPlaceCodes(placeCodes);
ap.setPlaceCode(placeCodes[0]);
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(materialById.getMid());
ap.setSplitInfoList(splitInfoByMid);
list.add(ap);
@ -926,7 +930,6 @@ public class DepositoryRecordController {
map.put("price", map.get("price").toString());
map.put("applicantId", userToken.getId());
Map<String, Object> param = new HashMap<>();
String placeCode = (String) map.get("placeCode");
placeCode = placeCode.trim();
param.put("code", placeCode);
@ -1042,6 +1045,7 @@ public class DepositoryRecordController {
List<String> placeCodes = (List<String>) map.get("placeCodes");
List<String> applyRemarks = (List<String>) map.get("applyRemarks");
List<Object> prices = (List<Object>) map.get("prices");
List<String> units = (List<String>)map.get("units");
String errMsg = "";
Integer id = 0;
if ("in".equals(type)) {
@ -1053,44 +1057,43 @@ public class DepositoryRecordController {
// 获取当前申请数量
Integer integer = ObjectFormatUtil.toInteger(quantitys.get(i));
String quantity = integer.toString();
// 获取每个库位编码
String[] s = placeCode.split(" ");
// 先定义最终要使用的库位,默认是默认库位
Integer place = 0;
if (s.length > 1) {
// 获取当前仓库所有库位
List<Place> placeByDid = placeService.findPlaceByDid(depositoryId);
// 遍历当前物料存储的库位
for (int j = 0; j < s.length; j++) {
Place place1 = placeByDid.get(j);
if (placeCode.equals(place1.getCode())) {
// 如果当前物料存放在当前库位
if (place1.getMax() - place1.getQuantity() >= integer) {
// 如果当前库位能够存放当前数量
place = place1.getId();
}
}
}
Integer placeId = 0;
if(!"0000".equals(placeCode)){
// 如果当前选择的不是默认库位
Place place = placeService.findPlaceByDidAndCode(depositoryId, placeCode);
placeId = place.getId();
}
Integer mid = mids.get(i);
String price = prices.get(i).toString();
String applyRemark = applyRemarks.get(i);
String unit = units.get(i);
Map<String, Object> inRecord = new HashMap<>();
inRecord.put("applicantId", userToken.getId());
inRecord.put("mid", mid);
inRecord.put("placeId", place);
inRecord.put("placeId", placeId);
inRecord.put("depositoryId", depositoryId);
inRecord.put("quantity", quantity);
inRecord.put("price", price);
inRecord.put("applyRemark", applyRemark);
success += depositoryRecordService.applicationInPlace(inRecord);
if (!"-1".equals(unit)) {
map.put("type","in");
Integer addSplitInventory = splitUnitService.addSplitInventory(inRecord);
if (addSplitInventory != -1) {
success += addSplitInventory;
}
} else {
success += depositoryRecordService.applicationInPlace(inRecord);
}
}
} else if ("out".equals(type)) {
Map<String, Object> mainRecord = new HashMap<>();
Integer sumQuantity = 0;
for (int i = 0; i < quantitys.size(); i++) {
Integer integer = ObjectFormatUtil.toInteger(quantitys.get(i));
for (Object o : quantitys) {
Integer integer = ObjectFormatUtil.toInteger(o);
sumQuantity += integer;
}
// 获取部门负责人

8
src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.java

@ -148,6 +148,14 @@ public interface PlaceMapper {
Integer updateMaterialAndPlace(MaterialAndPlace mp);
/**
* 根据仓库id及库位编码获取对应库位
* @param map 查询条件
* @return
*/
Place findPlaceByDidAndCode(Map<String,Object> map);
/**
* 获取当前库位当前物料的数量
* @param map

12
src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml

@ -62,6 +62,18 @@
</if>
</select>
<select id="findPlaceByDidAndCode" resultMap="placeMap" parameterType="map">
SELECT
<include refid="allColumns" />
FROM place p WHERE 1 = 1
<if test="code != '' and code != null">
and p.code = #{code}
</if>
<if test="did != '' and did != null">
and p.did = #{did}
</if>
</select>
<!-- 根据条件参数查询列表 -->
<select id="findPlaceByCondition" resultMap="placeMap" parameterType="map">
SELECT

10
src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationModel.java

@ -11,6 +11,8 @@ import java.util.List;
*/
@Data
public class ApplicationModel {
/**
* 仓库名称
*/
@ -72,9 +74,17 @@ public class ApplicationModel {
*/
private String unit;
/**
* 计量单位
*/
private String showUnit;
/**
* 该物料对应的拆单记录
*/
private List<SplitInfo> splitInfoList;
private String[] placeCodes;
}

9
src/main/java/com/dreamchaser/depository_manage/service/PlaceService.java

@ -72,6 +72,15 @@ public interface PlaceService {
*/
Place findPlaceById(Integer id);
/**
* 根据仓库id及库位编码获取对应库位
* @param did 仓库id
* @param code 库位编码
* @return
*/
Place findPlaceByDidAndCode(Integer did,String code);
/**
* 根据id将库位状态改为删除
* @param id

14
src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java

@ -155,6 +155,20 @@ public class PlaceServiceImpl implements PlaceService {
return placeMapper.findPlaceById(id);
}
/**
* 根据仓库id及库位编码获取对应库位
* @param did 仓库id
* @param code 库位编码
* @return
*/
@Override
public Place findPlaceByDidAndCode(Integer did, String code) {
Map<String,Object> paramForPlace = new HashMap<>();
paramForPlace.put("code",code);
paramForPlace.put("did",did);
return placeMapper.findPlaceByDidAndCode(paramForPlace);
}
/**
* 根据id将库位状态改为删除
* @param id

39
src/main/resources/templates/pages/application/application_multi.html

@ -45,7 +45,11 @@
<!-- 用于计量单位的展示-->
<script id="changeUnit" type="text/html">
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0" id="btn_{{d.id}}" value="{{d.unit}}">{{d.unit}}</button>
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0" id="btn_unit_{{d.id}}" value="-1">{{d.showUnit}}</button>
</script>
<script id="selectLocation" type="text/html">
<button class="layui-btn layui-btn-primary layui-btn-xs" click_num="0" lay-event="selectLocation" id="btn_placeCode_{{d.iid}}" value="{{d.placeCode}}">{{d.placeCode}}</button>
</script>
</div>
</div>
@ -87,13 +91,11 @@
{field: 'mname', width: 150, title: '物料名称'},
{field: 'version', width: 150, title: '规格型号'},
{field: 'code',width: 200,title: '存货编码',sort: true},
{title: '所处位置', width: 200, templet: '#selectLocation', align: "center"},
{field: 'depositoryName', width: 150, title: '仓库名称'},
{field: 'quantity', width: 150, title: '数量',edit:'quantity'},
{title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
// {rowspan: 2,title:'计量单位', width: 200, templet: '#selectUnit'},
{field: 'price', width: 150, title: '单价',edit:'price'},
{field: 'depositoryId', width: 150, title: '仓库编号'},
{field: 'applyRemark', width: 150, title: '备注说明',edit:'applyRemark'},
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
]
@ -112,8 +114,6 @@
}
});*/
}
});
@ -141,6 +141,7 @@
req.prices = [];
req.placeCodes = [];
req.iids = [];
req.units = [];
for (i = 0, len = data.length; i < len; i++) {
req.mids[i] = data[i].mid;
req.iids[i] = data[i].iid;
@ -149,6 +150,7 @@
req.applyRemarks[i] = data[i].applyRemark;
req.prices[i] = data[i].price;
req.placeCodes[i] = data[i].placeCode;
req.units[i] = data[i].unit;
}
if(obj.event==='delete'){
@ -332,7 +334,7 @@
}
else if (obj.event === 'changeUnit') {
let splitInfoList = data.splitInfoList;
let btn = $("#btn_"+data.id);
let btn = $("#btn_unit_"+data.id);
let clickNum = Number(btn.attr("click_num"));
if(splitInfoList.length > 0){
if(clickNum < splitInfoList.length){
@ -342,14 +344,31 @@
btn.attr("click_num",clickNum);
obj.update({unit:newUnit})
}else{
btn.text(data.unit);
obj.update({unit:data.unit})
btn.text(data.showUnit);
obj.update({unit:"-1"});
btn.attr("click_num",0);
}
}
}
else if(obj.event === 'selectLocation'){
let btn = $("#btn_placeCode_"+data.iid);
let placeCodes = data.placeCodes;
let clickNum = Number(btn.attr("click_num")) + 1;
if(placeCodes.length > 1){
if(clickNum < placeCodes.length){
let placeCode = placeCodes[clickNum];
clickNum += 1;
btn.attr("click_num",clickNum);
btn.text(placeCode);
obj.update({placeCode:placeCode})
}else{
btn.text(placeCodes[0]);
obj.update({placeCode:placeCodes[0]});
btn.attr("click_num",0);
}
}
}
});
});

2
src/main/resources/templates/pages/depository/table-stock.html

@ -266,7 +266,7 @@
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (data) {
if (data.status == 201) {
if (data.status === 201) {
layer.msg("添加成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)

12
target/classes/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml

@ -62,6 +62,18 @@
</if>
</select>
<select id="findPlaceByDidAndCode" resultMap="placeMap" parameterType="map">
SELECT
<include refid="allColumns" />
FROM place p WHERE 1 = 1
<if test="code != '' and code != null">
and p.code = #{code}
</if>
<if test="did != '' and did != null">
and p.did = #{did}
</if>
</select>
<!-- 根据条件参数查询列表 -->
<select id="findPlaceByCondition" resultMap="placeMap" parameterType="map">
SELECT

39
target/classes/templates/pages/application/application_multi.html

@ -45,7 +45,11 @@
<!-- 用于计量单位的展示-->
<script id="changeUnit" type="text/html">
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0" id="btn_{{d.id}}" value="{{d.unit}}">{{d.unit}}</button>
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0" id="btn_unit_{{d.id}}" value="-1">{{d.showUnit}}</button>
</script>
<script id="selectLocation" type="text/html">
<button class="layui-btn layui-btn-primary layui-btn-xs" click_num="0" lay-event="selectLocation" id="btn_placeCode_{{d.iid}}" value="{{d.placeCode}}">{{d.placeCode}}</button>
</script>
</div>
</div>
@ -87,13 +91,11 @@
{field: 'mname', width: 150, title: '物料名称'},
{field: 'version', width: 150, title: '规格型号'},
{field: 'code',width: 200,title: '存货编码',sort: true},
{title: '所处位置', width: 200, templet: '#selectLocation', align: "center"},
{field: 'depositoryName', width: 150, title: '仓库名称'},
{field: 'quantity', width: 150, title: '数量',edit:'quantity'},
{title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
// {rowspan: 2,title:'计量单位', width: 200, templet: '#selectUnit'},
{field: 'price', width: 150, title: '单价',edit:'price'},
{field: 'depositoryId', width: 150, title: '仓库编号'},
{field: 'applyRemark', width: 150, title: '备注说明',edit:'applyRemark'},
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
]
@ -112,8 +114,6 @@
}
});*/
}
});
@ -141,6 +141,7 @@
req.prices = [];
req.placeCodes = [];
req.iids = [];
req.units = [];
for (i = 0, len = data.length; i < len; i++) {
req.mids[i] = data[i].mid;
req.iids[i] = data[i].iid;
@ -149,6 +150,7 @@
req.applyRemarks[i] = data[i].applyRemark;
req.prices[i] = data[i].price;
req.placeCodes[i] = data[i].placeCode;
req.units[i] = data[i].unit;
}
if(obj.event==='delete'){
@ -332,7 +334,7 @@
}
else if (obj.event === 'changeUnit') {
let splitInfoList = data.splitInfoList;
let btn = $("#btn_"+data.id);
let btn = $("#btn_unit_"+data.id);
let clickNum = Number(btn.attr("click_num"));
if(splitInfoList.length > 0){
if(clickNum < splitInfoList.length){
@ -342,14 +344,31 @@
btn.attr("click_num",clickNum);
obj.update({unit:newUnit})
}else{
btn.text(data.unit);
obj.update({unit:data.unit})
btn.text(data.showUnit);
obj.update({unit:"-1"});
btn.attr("click_num",0);
}
}
}
else if(obj.event === 'selectLocation'){
let btn = $("#btn_placeCode_"+data.iid);
let placeCodes = data.placeCodes;
let clickNum = Number(btn.attr("click_num")) + 1;
if(placeCodes.length > 1){
if(clickNum < placeCodes.length){
let placeCode = placeCodes[clickNum];
clickNum += 1;
btn.attr("click_num",clickNum);
btn.text(placeCode);
obj.update({placeCode:placeCode})
}else{
btn.text(placeCodes[0]);
obj.update({placeCode:placeCodes[0]});
btn.attr("click_num",0);
}
}
}
});
});

2
target/classes/templates/pages/depository/table-stock.html

@ -266,7 +266,7 @@
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (data) {
if (data.status == 201) {
if (data.status === 201) {
layer.msg("添加成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)

Loading…
Cancel
Save