add : 半成品损溢
This commit is contained in:
@@ -89,6 +89,7 @@ public class StIvtMoreorlessmstCpServiceImpl extends ServiceImpl<StIvtMoreorless
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(JSONObject form) {
|
||||
JSONArray rows = form.getJSONArray("tableData");
|
||||
if (ObjectUtil.isEmpty(rows)) throw new BadRequestException("请求参数不能为空");
|
||||
@@ -113,6 +114,7 @@ public class StIvtMoreorlessmstCpServiceImpl extends ServiceImpl<StIvtMoreorless
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(JSONObject form) {
|
||||
Assert.notNull(new Object[]{form, form.get("mol_id")}, "请求参数不能为空");
|
||||
StIvtMoreorlessmstCp mst = form.toJavaObject(StIvtMoreorlessmstCp.class);
|
||||
@@ -125,6 +127,7 @@ public class StIvtMoreorlessmstCpServiceImpl extends ServiceImpl<StIvtMoreorless
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
StIvtMoreorlessmstCp dao = this.getOne(new QueryWrapper<StIvtMoreorlessmstCp>().eq("mol_id", id));
|
||||
|
||||
@@ -49,5 +49,12 @@ public class StIvtStructivtYlController {
|
||||
public ResponseEntity<Object> getStructIvt(StructIvtYLQuery query) {
|
||||
return new ResponseEntity<>(structivtYlService.getStructIvt(query), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getSemiProductIvt")
|
||||
@Log("查询可用的半成品库存")
|
||||
@ApiOperation("查询可用的半成品库存")
|
||||
public ResponseEntity<Object> getSemiProductIvt(StructIvtYLQuery query) {
|
||||
return new ResponseEntity<>(structivtYlService.getSemiProductIvt(query), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,4 +36,7 @@ public interface IStIvtStructivtYlService extends IService<StIvtStructivtYl> {
|
||||
* @return JSONObject
|
||||
*/
|
||||
Object getProductIvt(StructIvtYLQuery query, PageQuery page);
|
||||
|
||||
|
||||
Object getSemiProductIvt(StructIvtYLQuery query);
|
||||
}
|
||||
|
||||
@@ -24,5 +24,7 @@ public interface StIvtStructivtYlMapper extends BaseMapper<StIvtStructivtYl> {
|
||||
|
||||
List<Map> getProductIvt(@Param("query") StructIvtYLQuery query, @Param("pageQuery") PageQuery pageQuery);
|
||||
|
||||
List<Map> getSemiProductIvt(@Param("query") StructIvtYLQuery query);
|
||||
|
||||
List<Map> getStructIvt(@Param("query") StructIvtYLQuery query);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,42 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getSemiProductIvt" resultType="java.util.Map">
|
||||
SELECT
|
||||
ivt.*,
|
||||
mu.unit_name AS qty_unit_name,
|
||||
mb.material_code,
|
||||
mb.material_name,
|
||||
sa.sect_id,
|
||||
sa.sect_code,
|
||||
sa.sect_name,
|
||||
sa.struct_id,
|
||||
sa.struct_code,
|
||||
sa.struct_name,
|
||||
sa.storagevehicle_code,
|
||||
class.class_name
|
||||
FROM
|
||||
st_ivt_structivt_bcp ivt
|
||||
LEFT JOIN md_me_materialbase mb ON mb.material_id = ivt.material_id
|
||||
LEFT JOIN st_ivt_structattr sa ON sa.struct_id = ivt.struct_id
|
||||
LEFT JOIN md_pb_measureunit mu ON mu.measure_unit_id = ivt.qty_unit_id
|
||||
LEFT JOIN md_pb_classstandard class ON class.class_id = mb.material_type_id
|
||||
<where>
|
||||
ivt.canuse_qty > 0
|
||||
AND
|
||||
sa.lock_type = '0'
|
||||
<if test="query.material_search != null and query.material_search != ''">
|
||||
and (mb.material_code = #{query.material_search} OR mb.material_name = #{query.material_search})
|
||||
</if>
|
||||
<if test="query.sect_id != null and query.sect_id != ''">
|
||||
and sa.sect_id = #{query.sect_id}
|
||||
</if>
|
||||
<if test="query.struct_id != null and query.struct_id != ''">
|
||||
and sa.struct_id = #{query.struct_id}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getStructIvt" resultType="java.util.Map">
|
||||
SELECT
|
||||
ivt.*,
|
||||
|
||||
@@ -47,4 +47,9 @@ public class StIvtStructivtYlServiceImpl extends ServiceImpl<StIvtStructivtYlMap
|
||||
build.setTotalElements(page.getTotal());
|
||||
return build;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSemiProductIvt(StructIvtYLQuery query) {
|
||||
return this.baseMapper.getSemiProductIvt(query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
package org.nl.wms.storage_manage.semimanage.controller.moveOrLess;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dto.MoreOrlessQuery;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.IStIvtMoreorlessmstBcpService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -14,8 +21,57 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @since 2023-05-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/stIvtMoreorlessmstBcp")
|
||||
@RequestMapping("/api/stIvtMoreorlessmstBcp")
|
||||
public class StIvtMoreorlessmstBcpController {
|
||||
|
||||
@Autowired
|
||||
private IStIvtMoreorlessmstBcpService iStIvtMoreorlessmstBcpService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询损溢单")
|
||||
@ApiOperation("查询损溢单")
|
||||
public ResponseEntity<Object> query(MoreOrlessQuery query, PageQuery page) {
|
||||
return new ResponseEntity<>(iStIvtMoreorlessmstBcpService.pageQuery(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("创建损溢单")
|
||||
@ApiOperation("创建损溢单")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject whereJson) {
|
||||
iStIvtMoreorlessmstBcpService.create(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getMlDtl")
|
||||
@Log("查询损溢明细")
|
||||
@ApiOperation("查询损溢明细")
|
||||
public ResponseEntity<Object> getMlDtl(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(iStIvtMoreorlessmstBcpService.getMlDtl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Log("修改损溢单")
|
||||
@ApiOperation("修改损溢单")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson) {
|
||||
iStIvtMoreorlessmstBcpService.update(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@Log("删除入库单")
|
||||
@ApiOperation("删除入库单")
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids){
|
||||
iStIvtMoreorlessmstBcpService.delete(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/confirm")
|
||||
@Log("完成单据")
|
||||
@ApiOperation("完成单据")
|
||||
public ResponseEntity<Object> confirm(@RequestBody JSONObject whereJson) {
|
||||
iStIvtMoreorlessmstBcpService.confirm(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.moveOrLess;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dao.StIvtMoreorlessmstYl;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessdtlBcp;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessmstBcp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +20,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IStIvtMoreorlessdtlBcpService extends IService<StIvtMoreorlessdtlBcp> {
|
||||
|
||||
/**
|
||||
* 主单据使用
|
||||
* @param row
|
||||
* @param mst
|
||||
* @return
|
||||
*/
|
||||
double create(JSONArray row, StIvtMoreorlessmstBcp mst);
|
||||
|
||||
List<Map> getMlDtl(JSONObject form);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.moveOrLess;
|
||||
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessmstBcp;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dto.MoreOrlessQuery;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessmstBcp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +19,22 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IStIvtMoreorlessmstBcpService extends IService<StIvtMoreorlessmstBcp> {
|
||||
|
||||
Object pageQuery(MoreOrlessQuery query, PageQuery page);
|
||||
|
||||
void create(JSONObject jo);
|
||||
|
||||
List<Map> getMlDtl(JSONObject map);
|
||||
|
||||
void update(JSONObject map);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param ids
|
||||
* {
|
||||
* 主表id..
|
||||
* }
|
||||
*/
|
||||
void delete(Long[] ids);
|
||||
|
||||
void confirm(JSONObject form);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
@@ -24,6 +26,7 @@ public class StIvtMoreorlessdtlBcp implements Serializable {
|
||||
/**
|
||||
* 损溢单明细id
|
||||
*/
|
||||
@TableId
|
||||
private String mol_dtl_id;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
@@ -25,6 +27,7 @@ public class StIvtMoreorlessmstBcp implements Serializable {
|
||||
/**
|
||||
* 损溢单标识
|
||||
*/
|
||||
@TableId
|
||||
private String mol_id;
|
||||
|
||||
/**
|
||||
@@ -80,7 +83,7 @@ public class StIvtMoreorlessmstBcp implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date create_time;
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 审核人
|
||||
@@ -95,7 +98,7 @@ public class StIvtMoreorlessmstBcp implements Serializable {
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date audit_time;
|
||||
private String audit_time;
|
||||
|
||||
/**
|
||||
* 确认人
|
||||
@@ -110,7 +113,7 @@ public class StIvtMoreorlessmstBcp implements Serializable {
|
||||
/**
|
||||
* 确认时间
|
||||
*/
|
||||
private Date confirm_time;
|
||||
private String confirm_time;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.mapper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessdtlBcp;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 损溢单明细表 Mapper 接口
|
||||
@@ -13,4 +18,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface StIvtMoreorlessdtlBcpMapper extends BaseMapper<StIvtMoreorlessdtlBcp> {
|
||||
|
||||
List<Map> getMlDtl(@Param("map") JSONObject map);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dto.MoreOrlessQuery;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessmstBcp;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 损溢单主表 Mapper 接口
|
||||
@@ -13,4 +19,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface StIvtMoreorlessmstBcpMapper extends BaseMapper<StIvtMoreorlessmstBcp> {
|
||||
|
||||
List<Map> getMstDetail(@Param("query") MoreOrlessQuery query, @Param("pageQuery") PageQuery pageQuery);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,4 +2,20 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.mapper.StIvtMoreorlessdtlBcpMapper">
|
||||
|
||||
|
||||
<select id="getMlDtl" resultType="java.util.Map">
|
||||
SELECT
|
||||
dtl.*,
|
||||
mb.material_code,
|
||||
mb.material_name
|
||||
FROM
|
||||
st_ivt_moreorlessdtl_bcp dtl
|
||||
LEFT JOIN md_me_materialbase mb ON mb.material_id = dtl.material_id
|
||||
<where>
|
||||
<if test="map.mol_id != null and map.mol_id != ''">
|
||||
dtl.mol_id = #{map.mol_id}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -2,4 +2,58 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.mapper.StIvtMoreorlessmstBcpMapper">
|
||||
|
||||
<select id="getMstDetail" resultType="java.util.Map">
|
||||
SELECT
|
||||
mst.*,
|
||||
a.total_qty,
|
||||
a.struct_name,
|
||||
sa.struct_code,
|
||||
sa.struct_id,
|
||||
sa.sect_id,
|
||||
sa.sect_name
|
||||
FROM
|
||||
st_ivt_moreorlessmst_bcp mst
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
dtl.struct_name,
|
||||
dtl.struct_id,
|
||||
SUM( dtl.mol_qty ) AS total_qty,
|
||||
dtl.mol_id
|
||||
FROM
|
||||
st_ivt_moreorlessdtl_bcp dtl
|
||||
GROUP BY
|
||||
dtl.struct_name,
|
||||
dtl.mol_id,
|
||||
dtl.struct_id
|
||||
) a ON a.mol_id = mst.mol_id
|
||||
LEFT JOIN st_ivt_structattr sa ON sa.struct_id = a.struct_id
|
||||
<where>
|
||||
mst.is_delete = '0'
|
||||
<if test="query.start_time != null">
|
||||
and mst.create_time >= #{query.start_time}
|
||||
</if>
|
||||
<if test="query.end_time != null">
|
||||
and #{query.end_time} >= mst.create_time
|
||||
</if>
|
||||
<if test="query.stor_id != null and query.stor_id != ''">
|
||||
and mst.stor_id = #{query.stor_id}
|
||||
</if>
|
||||
<if test="query.status != null and query.status != ''">
|
||||
and mst.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.mol_inv_type != null and query.mol_inv_type != ''">
|
||||
and mst.mol_inv_type = #{query.mol_inv_type}
|
||||
</if>
|
||||
<if test="query.mol_code != null and query.mol_code != ''">
|
||||
and mst.mol_code = #{query.mol_code}
|
||||
</if>
|
||||
<if test="query.mol_type != null and query.mol_type != ''">
|
||||
and mst.mol_type = #{query.mol_type}
|
||||
</if>
|
||||
|
||||
order by mst.mol_code DESC
|
||||
</where>
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.moveOrLess.impl;
|
||||
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessdtlBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.mapper.StIvtMoreorlessdtlBcpMapper;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.IStIvtMoreorlessdtlBcpService;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.wms.masterdata_manage.service.vehicle.IMdPbStoragevehicleinfoService;
|
||||
import org.nl.wms.masterdata_manage.service.vehicle.dao.MdPbStoragevehicleinfo;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtSectattrService;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtStructattrService;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtSectattr;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtStructattr;
|
||||
import org.nl.wms.storage_manage.IOSEnum;
|
||||
import org.nl.wms.storage_manage.semimanage.MLEnum;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.IStIvtMoreorlessdtlBcpService;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessdtlBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessmstBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.mapper.StIvtMoreorlessdtlBcpMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 损溢单明细表 服务实现类
|
||||
@@ -17,4 +39,69 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class StIvtMoreorlessdtlBcpServiceImpl extends ServiceImpl<StIvtMoreorlessdtlBcpMapper, StIvtMoreorlessdtlBcp> implements IStIvtMoreorlessdtlBcpService {
|
||||
|
||||
@Autowired
|
||||
private IStIvtSectattrService sectattrService; // 库区服务
|
||||
|
||||
@Autowired
|
||||
private IStIvtStructattrService structattrService; // 仓位服务
|
||||
|
||||
@Autowired
|
||||
private IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService; // 载具服务
|
||||
|
||||
@Override
|
||||
public List<Map> getMlDtl(JSONObject form) {
|
||||
return this.baseMapper.getMlDtl(form);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double create(JSONArray rows, StIvtMoreorlessmstBcp mst) {
|
||||
double total_qty = 0;
|
||||
|
||||
if (rows.size() > 0 && ObjectUtil.isNotEmpty(mst)) {
|
||||
// 先删除在插入
|
||||
this.remove(new QueryWrapper<StIvtMoreorlessdtlBcp>().eq("mol_id", mst.getMol_id()));
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
String mol_dtl_id = IdUtil.getStringId();
|
||||
StIvtMoreorlessdtlBcp row = rows.getJSONObject(i).toJavaObject(StIvtMoreorlessdtlBcp.class);
|
||||
row.setMol_dtl_id(mol_dtl_id);
|
||||
row.setMol_id(mst.getMol_id());
|
||||
row.setMol_code(mst.getMol_code());
|
||||
row.setSeq_no(BigDecimal.valueOf(i + 1));
|
||||
row.setPcsn(DateUtil.today());
|
||||
|
||||
// 获取库区信息
|
||||
QueryWrapper<StIvtSectattr> sect_wrapper = new QueryWrapper<>();
|
||||
sect_wrapper.eq("sect_id", row.getSect_id());
|
||||
sect_wrapper.eq("is_used", true);
|
||||
StIvtSectattr sectDao = sectattrService.getOne(sect_wrapper);
|
||||
if (ObjectUtil.isEmpty(sectDao)) throw new BadRequestException("库区不存在或未启用!");
|
||||
row.setSect_name(sectDao.getSect_name());
|
||||
// 获取仓位信息
|
||||
QueryWrapper<StIvtStructattr> struct_wrapper = new QueryWrapper<>();
|
||||
struct_wrapper.eq("struct_id", row.getStruct_id());
|
||||
struct_wrapper.eq("is_used", true);
|
||||
StIvtStructattr structDao = structattrService.getOne(struct_wrapper);
|
||||
if (ObjectUtil.isEmpty(structDao)) throw new BadRequestException("仓位不存在或未启用!");
|
||||
row.setStruct_name(structDao.getStruct_name());
|
||||
|
||||
// 获取载具信息
|
||||
MdPbStoragevehicleinfo vehicleDao = iMdPbStoragevehicleinfoService.getOne(
|
||||
new QueryWrapper<MdPbStoragevehicleinfo>().lambda()
|
||||
.eq(MdPbStoragevehicleinfo::getStoragevehicle_code, row.getStoragevehicle_code())
|
||||
);
|
||||
|
||||
if (ObjectUtil.isEmpty(vehicleDao)) throw new BadRequestException("载具不存在!");
|
||||
|
||||
row.setStoragevehicle_id(vehicleDao.getStoragevehicle_id());
|
||||
row.setStoragevehicle_code(vehicleDao.getStoragevehicle_code());
|
||||
row.setStatus(MLEnum.DTL_STATUS.code("生成"));
|
||||
this.save(row);
|
||||
|
||||
//锁定货位
|
||||
structattrService.update(new UpdateWrapper<StIvtStructattr>().set("lock_type", IOSEnum.LOCK_TYPE.code("损溢锁")).set("inv_code",mst.getMol_code()).eq("struct_id", row.getStruct_id()));
|
||||
}
|
||||
}
|
||||
return total_qty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,46 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.moveOrLess.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.jsonwebtoken.lang.Assert;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtBsrealstorattrService;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtStructattrService;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtBsrealstorattr;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtStructattr;
|
||||
import org.nl.wms.storage_manage.CHECKEnum;
|
||||
import org.nl.wms.storage_manage.IOSEnum;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dto.MoreOrlessQuery;
|
||||
import org.nl.wms.storage_manage.semimanage.MLEnum;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.IStIvtMoreorlessdtlBcpService;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.IStIvtMoreorlessmstBcpService;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessdtlBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.StIvtMoreorlessmstBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.dao.mapper.StIvtMoreorlessmstBcpMapper;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.IStIvtMoreorlessmstBcpService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.wms.storage_manage.semimanage.service.structIvt.IStIvtStructivtBcpService;
|
||||
import org.nl.wms.storage_manage.semimanage.service.structIvt.dao.StIvtStructivtBcp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -17,4 +53,233 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class StIvtMoreorlessmstBcpServiceImpl extends ServiceImpl<StIvtMoreorlessmstBcpMapper, StIvtMoreorlessmstBcp> implements IStIvtMoreorlessmstBcpService {
|
||||
|
||||
@Autowired
|
||||
private IStIvtMoreorlessdtlBcpService iStIvtMoreorlessdtlBcpService; // 半成品明细服务
|
||||
|
||||
@Autowired
|
||||
private IStIvtBsrealstorattrService stIvtBsrealstorattrService; // 实物属性服务
|
||||
|
||||
@Autowired
|
||||
private IStIvtStructivtBcpService iStIvtStructivtBcpService; // 半成品库存服务
|
||||
|
||||
@Autowired
|
||||
private IStIvtStructattrService structattrService; // 仓位服务
|
||||
|
||||
@Override
|
||||
public Object pageQuery(MoreOrlessQuery query, PageQuery pageQuery) {
|
||||
Page<Object> page = PageHelper.startPage(pageQuery.getPage() + 1, pageQuery.getSize());
|
||||
List<Map> mst_detail = this.baseMapper.getMstDetail(query, pageQuery);
|
||||
TableDataInfo<Map> build = TableDataInfo.build(mst_detail);
|
||||
build.setTotalElements(page.getTotal());
|
||||
return build;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(JSONObject form) {
|
||||
JSONArray rows = form.getJSONArray("tableData");
|
||||
if (ObjectUtil.isEmpty(rows)) throw new BadRequestException("请求参数不能为空");
|
||||
|
||||
// 调用主表 插入/更新方法
|
||||
StIvtMoreorlessmstBcp mlmstYl = packageMstForm(new StIvtMoreorlessmstBcp(), form);
|
||||
this.save(mlmstYl);
|
||||
|
||||
//调用明细表 插入方法
|
||||
iStIvtMoreorlessdtlBcpService.create(rows, mlmstYl);
|
||||
|
||||
if (form.containsKey("auto_confirm") && form.getString("auto_confirm").equals("1")) {
|
||||
JSONObject mst = new JSONObject();
|
||||
mst.put("mol_id", mlmstYl.getMol_id());
|
||||
this.confirm(mst);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getMlDtl(JSONObject map) {
|
||||
return iStIvtMoreorlessdtlBcpService.getMlDtl(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(JSONObject form) {
|
||||
Assert.notNull(new Object[]{form, form.get("mol_id")}, "请求参数不能为空");
|
||||
StIvtMoreorlessmstBcp mst = form.toJavaObject(StIvtMoreorlessmstBcp.class);
|
||||
this.updateById(mst);
|
||||
|
||||
JSONArray rows = form.getJSONArray("tableData");
|
||||
if (ObjectUtil.isEmpty(rows)) throw new BadRequestException("请求参数不能为空");
|
||||
// 调用明细表 插入/更新方法
|
||||
iStIvtMoreorlessdtlBcpService.create(rows, mst);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
StIvtMoreorlessmstBcp dao = this.getOne(new QueryWrapper<StIvtMoreorlessmstBcp>().eq("mol_id", id));
|
||||
dao.setIs_delete(true);
|
||||
this.updateById(dao);
|
||||
|
||||
|
||||
// 解锁货位
|
||||
StIvtMoreorlessdtlBcp dtlDao = iStIvtMoreorlessdtlBcpService.getOne(
|
||||
new QueryWrapper<StIvtMoreorlessdtlBcp>().lambda()
|
||||
.eq(StIvtMoreorlessdtlBcp::getMol_id, id),
|
||||
false
|
||||
);
|
||||
|
||||
structattrService.update(
|
||||
new StIvtStructattr()
|
||||
.setInv_code("")
|
||||
.setInv_type("")
|
||||
.setInv_id("")
|
||||
.setLock_type(IOSEnum.LOCK_TYPE.code("未锁定")),
|
||||
new QueryWrapper<StIvtStructattr>().lambda()
|
||||
.eq(StIvtStructattr::getStruct_id, dtlDao.getStruct_id())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirm(JSONObject whereJson) {
|
||||
|
||||
String mol_id = (String) whereJson.get("mol_id");
|
||||
|
||||
StIvtMoreorlessmstBcp mst = this.getOne(new QueryWrapper<StIvtMoreorlessmstBcp>().eq("mol_id", mol_id));
|
||||
|
||||
if (!mst.getStatus().equals(MLEnum.BILL_STATUS.code("生成"))) {
|
||||
throw new BadRequestException("请选择单据状态为生成的损溢单!");
|
||||
}
|
||||
|
||||
String mol_type = mst.getMol_type();
|
||||
|
||||
List<StIvtMoreorlessdtlBcp> dtl_list = iStIvtMoreorlessdtlBcpService.list(new QueryWrapper<StIvtMoreorlessdtlBcp>().eq("mol_id", mol_id));
|
||||
//更新库存
|
||||
if (mol_type.equals(MLEnum.MOL_TYPE.code("损"))) {
|
||||
dtl_list.forEach(dtl -> {
|
||||
StIvtStructivtBcp ivt = iStIvtStructivtBcpService.getOne(new QueryWrapper<StIvtStructivtBcp>().eq("struct_id", dtl.getStruct_id()).eq("material_id", dtl.getMaterial_id()));
|
||||
if (ObjectUtil.isEmpty(ivt)) {
|
||||
throw new BadRequestException("未查询到相关库存!");
|
||||
}
|
||||
BigDecimal canuse_qty = ivt.getCanuse_qty();
|
||||
BigDecimal mol_qty = dtl.getMol_qty();
|
||||
ivt.setCanuse_qty(NumberUtil.sub(canuse_qty, mol_qty));
|
||||
//如果库存变为0则删除记录
|
||||
if (canuse_qty.compareTo(mol_qty) == 0 ) {
|
||||
iStIvtStructivtBcpService.removeById(ivt.getStruct_id());
|
||||
|
||||
// 更新货位 -- 清除载具号
|
||||
structattrService.update(
|
||||
new StIvtStructattr()
|
||||
.setStoragevehicle_code("")
|
||||
.setInv_id("")
|
||||
.setInv_type("")
|
||||
.setInv_code(""),
|
||||
new QueryWrapper<StIvtStructattr>().lambda()
|
||||
.eq(StIvtStructattr::getStruct_id, ivt.getStruct_id())
|
||||
);
|
||||
} else {
|
||||
iStIvtStructivtBcpService.updateById(ivt);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dtl_list.forEach(dtl -> {
|
||||
StIvtStructivtBcp ivt = iStIvtStructivtBcpService.getOne(new QueryWrapper<StIvtStructivtBcp>().eq("struct_id", dtl.getStruct_id()).eq("material_id", dtl.getMaterial_id()));
|
||||
BigDecimal mol_qty = dtl.getMol_qty();
|
||||
|
||||
if (ObjectUtil.isEmpty(ivt)) {
|
||||
StIvtStructattr struct_jo = structattrService.getOne(new QueryWrapper<StIvtStructattr>().eq("struct_id", dtl.getStruct_id()));
|
||||
//新增一条库存记录
|
||||
iStIvtStructivtBcpService.save(StIvtStructivtBcp.builder()
|
||||
.struct_id(dtl.getStruct_id())
|
||||
.struct_code(struct_jo.getStruct_code())
|
||||
.struct_name(struct_jo.getStruct_name())
|
||||
.material_id(dtl.getMaterial_id())
|
||||
.quality_scode(dtl.getQuality_scode())
|
||||
.pcsn(dtl.getPcsn())
|
||||
.ivt_level(dtl.getIvt_level())
|
||||
.is_active(dtl.getIs_active())
|
||||
.canuse_qty(mol_qty)
|
||||
.qty_unit_id(dtl.getQty_unit_id())
|
||||
.instorage_time(DateUtil.now())
|
||||
.stor_id(mst.getStor_id())
|
||||
.workshop_id(mst.getProduct_area())
|
||||
.is_pick(false)
|
||||
.build()
|
||||
);
|
||||
|
||||
// 更新仓位
|
||||
struct_jo.setStoragevehicle_code(dtl.getStoragevehicle_code());
|
||||
structattrService.updateById(struct_jo);
|
||||
|
||||
} else {
|
||||
BigDecimal canuse_qty = ivt.getCanuse_qty();
|
||||
ivt.setCanuse_qty(NumberUtil.add(canuse_qty, mol_qty));
|
||||
iStIvtStructivtBcpService.updateById(ivt);
|
||||
}
|
||||
|
||||
//更新明细状态
|
||||
dtl.setStatus(MLEnum.DTL_STATUS.code("确认完成"));
|
||||
iStIvtMoreorlessdtlBcpService.updateById(dtl);
|
||||
});
|
||||
}
|
||||
|
||||
dtl_list.stream().map(dtl -> dtl.getStruct_id())
|
||||
.distinct()
|
||||
.forEach(struct_id -> structattrService.update(
|
||||
new UpdateWrapper<StIvtStructattr>().lambda()
|
||||
.set(StIvtStructattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
|
||||
.set(StIvtStructattr::getInv_code, "")
|
||||
.eq(StIvtStructattr::getStruct_id, struct_id))
|
||||
);
|
||||
|
||||
//更新损溢单主表
|
||||
mst.setStatus(MLEnum.BILL_STATUS.code("完成"));
|
||||
mst.setConfirm_optid(SecurityUtils.getCurrentUserId());
|
||||
mst.setConfirm_optname(SecurityUtils.getCurrentNickName());
|
||||
mst.setConfirm_time(DateUtil.now());
|
||||
this.updateById(mst);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private StIvtMoreorlessmstBcp packageMstForm(StIvtMoreorlessmstBcp mlmstYl, JSONObject whereJson) {
|
||||
JSONArray rows = whereJson.getJSONArray("tableData");
|
||||
// 新增
|
||||
mlmstYl.setMol_id(IdUtil.getStringId());
|
||||
mlmstYl.setMol_code(CodeUtil.getNewCode("MOL_CODE"));
|
||||
if (StrUtil.isEmpty(whereJson.getString("buss_type"))) {
|
||||
mlmstYl.setBuss_type(MLEnum.BILL_TYPE.code("普通损溢"));
|
||||
mlmstYl.setMol_inv_type(MLEnum.BILL_TYPE.code("普通损溢"));
|
||||
} else {
|
||||
mlmstYl.setBuss_type(whereJson.getString("buss_type"));
|
||||
mlmstYl.setMol_inv_type(whereJson.getString("buss_type"));
|
||||
}
|
||||
|
||||
mlmstYl.setMol_type(whereJson.getString("mol_type"));
|
||||
|
||||
// 获取仓库信息
|
||||
QueryWrapper<StIvtBsrealstorattr> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("stor_id", whereJson.getString("stor_id"));
|
||||
wrapper.eq("is_used", true);
|
||||
StIvtBsrealstorattr bsrealDao = stIvtBsrealstorattrService.getOne(wrapper);
|
||||
if (ObjectUtil.isEmpty(bsrealDao)) throw new BadRequestException("仓库不存在或未启用!");
|
||||
|
||||
mlmstYl.setStor_id(bsrealDao.getStor_id());
|
||||
mlmstYl.setStor_name(bsrealDao.getStor_name());
|
||||
mlmstYl.setDtl_num(BigDecimal.valueOf(rows.size()));
|
||||
mlmstYl.setCreate_mode(CHECKEnum.CREATE_MODE.code("PC产生"));
|
||||
mlmstYl.setStatus(CHECKEnum.BILL_STATUS.code("生成"));
|
||||
mlmstYl.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
mlmstYl.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
mlmstYl.setCreate_time(DateUtil.now());
|
||||
mlmstYl.setIs_delete(false);
|
||||
// TODO 暂时写死
|
||||
mlmstYl.setSysdeptid("111");
|
||||
mlmstYl.setSyscompanyid("111");
|
||||
|
||||
mlmstYl.setRemark(whereJson.getString("remark"));
|
||||
|
||||
return mlmstYl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user