Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -109,5 +109,13 @@ public class IStivtlostorivnCpOutController {
|
||||
return new ResponseEntity<>(iStIvtIostorinvCpOutService.getStructIvt(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/manualDiv")
|
||||
@Log("手工分配保存")
|
||||
@ApiOperation("手工分配保存")
|
||||
public ResponseEntity<Object> manualDiv(@RequestBody JSONObject whereJson){
|
||||
iStIvtIostorinvCpOutService.manualDiv(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
package org.nl.wms.storage_manage.productmanage.controller.moreOrLess;
|
||||
|
||||
|
||||
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.productmanage.service.moreOrLess.IStIvtMoreorlessmstCpService;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dto.MoreOrlessQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,8 +21,57 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @since 2023-05-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/stIvtMoreorlessmstCp")
|
||||
@RequestMapping("/api/stIvtMoreorlessmstCp")
|
||||
public class StIvtMoreorlessmstCpController {
|
||||
|
||||
@Autowired
|
||||
private IStIvtMoreorlessmstCpService iStIvtMoreorlessmstCpService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询损溢单")
|
||||
@ApiOperation("查询损溢单")
|
||||
public ResponseEntity<Object> query(MoreOrlessQuery query, PageQuery page) {
|
||||
return new ResponseEntity<>(iStIvtMoreorlessmstCpService.pageQuery(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("创建损溢单")
|
||||
@ApiOperation("创建损溢单")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject whereJson) {
|
||||
iStIvtMoreorlessmstCpService.create(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getMlDtl")
|
||||
@Log("查询损溢明细")
|
||||
@ApiOperation("查询损溢明细")
|
||||
public ResponseEntity<Object> getMlDtl(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(iStIvtMoreorlessmstCpService.getMlDtl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Log("修改损溢单")
|
||||
@ApiOperation("修改损溢单")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson) {
|
||||
iStIvtMoreorlessmstCpService.update(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@Log("删除入库单")
|
||||
@ApiOperation("删除入库单")
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids){
|
||||
iStIvtMoreorlessmstCpService.delete(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/confirm")
|
||||
@Log("完成单据")
|
||||
@ApiOperation("完成单据")
|
||||
public ResponseEntity<Object> confirm(@RequestBody JSONObject whereJson) {
|
||||
iStIvtMoreorlessmstCpService.confirm(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -131,4 +131,14 @@ public interface IStIvtIostorinvCpOutService extends IService<StIvtIostorinvCp>
|
||||
* }
|
||||
*/
|
||||
List getStructIvt(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 手工分配保存
|
||||
* @param whereJson
|
||||
* {
|
||||
* rows:库存,
|
||||
* iostorinvdtl_id:明细id,
|
||||
* }
|
||||
*/
|
||||
void manualDiv(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -478,11 +479,59 @@ public class StIvtIostorinvCpOutServiceImpl extends ServiceImpl<StIvtIostorinvCp
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("materia_id", whereJson.getString("materia_id"));
|
||||
param.put("stor_id", whereJson.getString("stor_id"));
|
||||
if (ObjectUtil.isNotEmpty(whereJson.getString("sale_id"))) param.put("sale_id", whereJson.getString("sale_id"));
|
||||
if (ObjectUtil.isNotEmpty(whereJson.getString("source_billdtl_id"))) param.put("sale_id", whereJson.getString("source_billdtl_id"));
|
||||
if (ObjectUtil.isNotEmpty(whereJson.getString("search"))) param.put("remark", whereJson.getString("search"));
|
||||
if (ObjectUtil.isNotEmpty(whereJson.getString("sect_id"))) param.put("sect_id", whereJson.getString("sect_id"));
|
||||
|
||||
return iStIvtStructivtCpService.getStructIvt(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void manualDiv(JSONObject whereJson) {
|
||||
|
||||
JSONArray rows = whereJson.getJSONArray("rows");
|
||||
|
||||
// 1.组织要更新库存的集合
|
||||
ArrayList<StIvtStructivtCp> ivtDaoList = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject jsonObject = rows.getJSONObject(i);
|
||||
StIvtStructivtCp ivtDao = iStIvtStructivtCpService.getById(jsonObject.getString("stockrecord_id"));
|
||||
ivtDao.setCanuse_qty(jsonObject.getBigDecimal("plan_qty"));
|
||||
|
||||
ivtDaoList.add(ivtDao);
|
||||
}
|
||||
|
||||
// 2.插入分配表
|
||||
StIvtIostorinvdtlCp dtlDao = iostorinvdtlCpService.getById(whereJson.getString("iostorinvdtl_id"));
|
||||
iostorinvdisCpService.onductDataOutDis(ivtDaoList,dtlDao);
|
||||
|
||||
// 3.更新明细状态
|
||||
BigDecimal assign_qty = ivtDaoList.stream()
|
||||
.map(StIvtStructivtCp::getCanuse_qty)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add); // 已分配数量
|
||||
|
||||
BigDecimal unassign_qty = NumberUtil.sub(dtlDao.getUnassign_qty(), assign_qty); // 未分配重量
|
||||
|
||||
if (unassign_qty.doubleValue() != 0) {
|
||||
dtlDao.setBill_status(IOSEnum.BILL_STATUS.code("分配中"));
|
||||
} else {
|
||||
dtlDao.setBill_status(IOSEnum.BILL_STATUS.code("分配完"));
|
||||
}
|
||||
|
||||
dtlDao.setUnassign_qty(unassign_qty);
|
||||
dtlDao.setAssign_qty(assign_qty);
|
||||
iostorinvdtlCpService.updateById(dtlDao);
|
||||
|
||||
// 4.更新库存冻结数 、 锁定仓位
|
||||
StIvtIostorinvCp mstDao = this.getById(dtlDao.getIostorinv_id());
|
||||
updateIvtDiv(ivtDaoList,mstDao);
|
||||
|
||||
// 5.更新主表
|
||||
updateMst(mstDao.getIostorinv_id());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private StIvtIostorinvCp packageMstForm(StIvtIostorinvCp stIvtIostorinvCp,JSONObject whereJson,Boolean isUpdate) {
|
||||
JSONArray rows = whereJson.getJSONArray("tableData");
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package org.nl.wms.storage_manage.productmanage.service.moreOrLess;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreorlessdtlCp;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreorlessmstCp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +19,13 @@ import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreo
|
||||
*/
|
||||
public interface IStIvtMoreorlessdtlCpService extends IService<StIvtMoreorlessdtlCp> {
|
||||
|
||||
/**
|
||||
* 主单据使用
|
||||
* @param row
|
||||
* @param mst
|
||||
* @return
|
||||
*/
|
||||
double create(JSONArray row, StIvtMoreorlessmstCp mst);
|
||||
|
||||
List<Map> getMlDtl(JSONObject form);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package org.nl.wms.storage_manage.productmanage.service.moreOrLess;
|
||||
|
||||
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.productmanage.service.moreOrLess.dao.StIvtMoreorlessmstCp;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dto.MoreOrlessQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +19,22 @@ import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreo
|
||||
*/
|
||||
public interface IStIvtMoreorlessmstCpService extends IService<StIvtMoreorlessmstCp> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class StIvtMoreorlessmstCp implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime create_time;
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 审核人
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.mapper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreorlessdtlCp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 损溢单明细表 Mapper 接口
|
||||
@@ -13,4 +18,6 @@ import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreo
|
||||
*/
|
||||
public interface StIvtMoreorlessdtlCpMapper extends BaseMapper<StIvtMoreorlessdtlCp> {
|
||||
|
||||
List<Map> getMlDtl(@Param("map") JSONObject map);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,4 +2,19 @@
|
||||
<!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.productmanage.service.moreOrLess.dao.mapper.StIvtMoreorlessdtlCpMapper">
|
||||
|
||||
<select id="getMlDtl" resultType="java.util.Map">
|
||||
SELECT
|
||||
dtl.*,
|
||||
mb.material_code,
|
||||
mb.material_name
|
||||
FROM
|
||||
st_ivt_moreorlessdtl_cp 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>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreorlessmstCp;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dto.MoreOrlessQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +19,6 @@ import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreo
|
||||
*/
|
||||
public interface StIvtMoreorlessmstCpMapper extends BaseMapper<StIvtMoreorlessmstCp> {
|
||||
|
||||
List<Map> getMstDetail(@Param("query") MoreOrlessQuery query, @Param("pageQuery") PageQuery pageQuery);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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.productmanage.service.moreOrLess.dao.mapper.StIvtMoreorlessmstCpMapper">
|
||||
<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_cp mst
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
dtl.struct_name,
|
||||
dtl.struct_id,
|
||||
SUM( dtl.mol_qty ) AS total_qty,
|
||||
dtl.mol_id
|
||||
FROM
|
||||
st_ivt_moreorlessdtl_yl 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>
|
||||
</where>
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,11 +1,31 @@
|
||||
package org.nl.wms.storage_manage.productmanage.service.moreOrLess.impl;
|
||||
|
||||
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.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.productmanage.service.moreOrLess.IStIvtMoreorlessdtlCpService;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreorlessdtlCp;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreorlessmstCp;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.mapper.StIvtMoreorlessdtlCpMapper;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dao.StIvtMoreorlessdtlYl;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dao.StIvtMoreorlessmstYl;
|
||||
import org.nl.wms.storage_manage.semimanage.MLEnum;
|
||||
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 +37,57 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class StIvtMoreorlessdtlCpServiceImpl extends ServiceImpl<StIvtMoreorlessdtlCpMapper, StIvtMoreorlessdtlCp> implements IStIvtMoreorlessdtlCpService {
|
||||
|
||||
@Autowired
|
||||
private IStIvtSectattrService sectattrService; // 库区属性服务
|
||||
|
||||
@Autowired
|
||||
private IStIvtStructattrService structattrService; // 仓位属性服务
|
||||
|
||||
@Override
|
||||
public List<Map> getMlDtl(JSONObject form) {
|
||||
return this.baseMapper.getMlDtl(form);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double create(JSONArray rows, StIvtMoreorlessmstCp mst) {
|
||||
double total_qty = 0;
|
||||
|
||||
if (rows.size() > 0 && ObjectUtil.isNotEmpty(mst)) {
|
||||
// 先删除在插入
|
||||
this.remove(new QueryWrapper<StIvtMoreorlessdtlCp>().eq("mol_id", mst.getMol_id()));
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
String mol_dtl_id = IdUtil.getStringId();
|
||||
StIvtMoreorlessdtlCp row = rows.getJSONObject(i).toJavaObject(StIvtMoreorlessdtlCp.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));
|
||||
|
||||
// 获取库区信息
|
||||
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());
|
||||
|
||||
row.setStoragevehicle_id("999999");
|
||||
row.setStoragevehicle_code("999999");
|
||||
row.setStatus(MLEnum.DTL_STATUS.code("生成"));
|
||||
this.save(row);
|
||||
|
||||
//锁定货位
|
||||
structattrService.update(new UpdateWrapper<StIvtStructattr>().set("lock_type", "1").set("inv_code",mst.getMol_code()).eq("struct_id", row.getStruct_id()));
|
||||
}
|
||||
}
|
||||
return total_qty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,48 @@
|
||||
package org.nl.wms.storage_manage.productmanage.service.moreOrLess.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.productmanage.service.moreOrLess.IStIvtMoreorlessdtlCpService;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.IStIvtMoreorlessmstCpService;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreorlessdtlCp;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.StIvtMoreorlessmstCp;
|
||||
import org.nl.wms.storage_manage.productmanage.service.moreOrLess.dao.mapper.StIvtMoreorlessmstCpMapper;
|
||||
import org.nl.wms.storage_manage.productmanage.service.structIvt.IStIvtStructivtCpService;
|
||||
import org.nl.wms.storage_manage.productmanage.service.structIvt.dao.StIvtStructivtCp;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dao.StIvtMoreorlessdtlYl;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dao.StIvtMoreorlessmstYl;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.moveOrLess.dto.MoreOrlessQuery;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.structIvt.dao.StIvtStructivtYl;
|
||||
import org.nl.wms.storage_manage.semimanage.MLEnum;
|
||||
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 +54,193 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class StIvtMoreorlessmstCpServiceImpl extends ServiceImpl<StIvtMoreorlessmstCpMapper, StIvtMoreorlessmstCp> implements IStIvtMoreorlessmstCpService {
|
||||
|
||||
@Autowired
|
||||
private IStIvtMoreorlessdtlCpService iStIvtMoreorlessdtlCpService; // 损益明细服务
|
||||
|
||||
@Autowired
|
||||
private IStIvtBsrealstorattrService stIvtBsrealstorattrService; // 实物属性服务
|
||||
|
||||
@Autowired
|
||||
private IStIvtStructivtCpService iStIvtStructivtCpService; // 库存服务
|
||||
|
||||
@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
|
||||
public void create(JSONObject form) {
|
||||
JSONArray rows = form.getJSONArray("tableData");
|
||||
if (ObjectUtil.isEmpty(rows)) throw new BadRequestException("请求参数不能为空");
|
||||
|
||||
// 调用主表 插入/更新方法
|
||||
StIvtMoreorlessmstCp mlmstCP = packageMstForm(new StIvtMoreorlessmstCp(), form);
|
||||
this.save(mlmstCP);
|
||||
|
||||
//调用明细表 插入方法
|
||||
iStIvtMoreorlessdtlCpService.create(rows, mlmstCP);
|
||||
|
||||
if (form.containsKey("auto_confirm") && form.getString("auto_confirm").equals("1")) {
|
||||
JSONObject mst = new JSONObject();
|
||||
mst.put("mol_id", mlmstCP.getMol_id());
|
||||
this.confirm(mst);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getMlDtl(JSONObject map) {
|
||||
return iStIvtMoreorlessdtlCpService.getMlDtl(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(JSONObject form) {
|
||||
Assert.notNull(new Object[]{form, form.get("mol_id")}, "请求参数不能为空");
|
||||
StIvtMoreorlessmstCp mst = form.toJavaObject(StIvtMoreorlessmstCp.class);
|
||||
this.updateById(mst);
|
||||
|
||||
JSONArray rows = form.getJSONArray("tableData");
|
||||
if (ObjectUtil.isEmpty(rows)) throw new BadRequestException("请求参数不能为空");
|
||||
// 调用明细表 插入/更新方法
|
||||
iStIvtMoreorlessdtlCpService.create(rows, mst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
StIvtMoreorlessmstCp dao = this.getOne(new QueryWrapper<StIvtMoreorlessmstCp>().eq("mol_id", id));
|
||||
dao.setIs_delete(true);
|
||||
this.updateById(dao);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirm(JSONObject whereJson) {
|
||||
|
||||
String mol_id = (String) whereJson.get("mol_id");
|
||||
|
||||
StIvtMoreorlessmstCp mst = this.getOne(new QueryWrapper<StIvtMoreorlessmstCp>().eq("mol_id", mol_id));
|
||||
|
||||
if (!mst.getStatus().equals(MLEnum.BILL_STATUS.code("生成"))) {
|
||||
throw new BadRequestException("请选择单据状态为生成的损溢单!");
|
||||
}
|
||||
|
||||
String mol_type = mst.getMol_type();
|
||||
|
||||
List<StIvtMoreorlessdtlCp> dtl_list = iStIvtMoreorlessdtlCpService.list(new QueryWrapper<StIvtMoreorlessdtlCp>().eq("mol_id", mol_id));
|
||||
//更新库存
|
||||
if (mol_type.equals(MLEnum.MOL_TYPE.code("损"))) {
|
||||
dtl_list.forEach(dtl -> {
|
||||
StIvtStructivtCp ivt = iStIvtStructivtCpService.getOne(new QueryWrapper<StIvtStructivtCp>().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 ivt_qty = ivt.getIvt_qty();
|
||||
BigDecimal mol_qty = dtl.getMol_qty();
|
||||
ivt.setCanuse_qty(NumberUtil.sub(canuse_qty, mol_qty));
|
||||
ivt.setIvt_qty(NumberUtil.sub(ivt_qty, mol_qty));
|
||||
//如果库存变为0则删除记录
|
||||
if (canuse_qty.compareTo(mol_qty) == 0 && canuse_qty.compareTo(ivt_qty) == 0) {
|
||||
iStIvtStructivtCpService.removeById(ivt.getStockrecord_id());
|
||||
} else {
|
||||
iStIvtStructivtCpService.updateById(ivt);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dtl_list.forEach(dtl -> {
|
||||
StIvtStructivtCp ivt = iStIvtStructivtCpService.getOne(new QueryWrapper<StIvtStructivtCp>().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()));
|
||||
//新增一条库存记录
|
||||
iStIvtStructivtCpService.save(new StIvtStructivtCp()
|
||||
.setStockrecord_id(IdUtil.getStringId())
|
||||
.setStruct_id(dtl.getStruct_id())
|
||||
.setStruct_code(struct_jo.getStruct_code())
|
||||
.setStruct_name(struct_jo.getStruct_name())
|
||||
.setMaterial_id(dtl.getMaterial_id())
|
||||
.setQuality_scode(dtl.getQuality_scode())
|
||||
.setPcsn(dtl.getPcsn())
|
||||
.setIvt_level(dtl.getIvt_level())
|
||||
.setIs_active(dtl.getIs_active())
|
||||
.setCanuse_qty(mol_qty)
|
||||
.setIvt_qty(mol_qty)
|
||||
.setQty_unit_id(dtl.getQty_unit_id())
|
||||
.setInstorage_time(DateUtil.now())
|
||||
.setStor_id(mst.getStor_id())
|
||||
);
|
||||
} else {
|
||||
BigDecimal canuse_qty = ivt.getCanuse_qty();
|
||||
BigDecimal ivt_qty = ivt.getIvt_qty();
|
||||
ivt.setCanuse_qty(NumberUtil.add(canuse_qty, mol_qty));
|
||||
ivt.setIvt_qty(NumberUtil.add(ivt_qty, mol_qty));
|
||||
iStIvtStructivtCpService.updateById(ivt);
|
||||
}
|
||||
|
||||
//更新明细状态
|
||||
dtl.setStatus(MLEnum.DTL_STATUS.code("确认完成"));
|
||||
iStIvtMoreorlessdtlCpService.updateById(dtl);
|
||||
});
|
||||
}
|
||||
|
||||
dtl_list.stream().map(dtl -> dtl.getStruct_id())
|
||||
.distinct()
|
||||
.forEach(struct_id -> structattrService.update(new UpdateWrapper<StIvtStructattr>().set("lock_type", "0").set("inv_code", "").eq("struct_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 StIvtMoreorlessmstCp packageMstForm(StIvtMoreorlessmstCp mlmstCP, JSONObject whereJson) {
|
||||
JSONArray rows = whereJson.getJSONArray("tableData");
|
||||
// 新增
|
||||
mlmstCP.setMol_id(IdUtil.getStringId());
|
||||
mlmstCP.setMol_code(CodeUtil.getNewCode("MOL_CODE"));
|
||||
if (StrUtil.isEmpty(whereJson.getString("buss_type"))) {
|
||||
mlmstCP.setBuss_type(MLEnum.BILL_TYPE.code("普通损溢"));
|
||||
mlmstCP.setMol_inv_type(MLEnum.BILL_TYPE.code("普通损溢"));
|
||||
} else {
|
||||
mlmstCP.setBuss_type(whereJson.getString("buss_type"));
|
||||
mlmstCP.setMol_inv_type(whereJson.getString("buss_type"));
|
||||
}
|
||||
|
||||
mlmstCP.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("仓库不存在或未启用!");
|
||||
|
||||
mlmstCP.setStor_id(bsrealDao.getStor_id());
|
||||
mlmstCP.setStor_name(bsrealDao.getStor_name());
|
||||
mlmstCP.setDtl_num(BigDecimal.valueOf(rows.size()));
|
||||
mlmstCP.setCreate_mode(CHECKEnum.CREATE_MODE.code("PC产生"));
|
||||
mlmstCP.setStatus(CHECKEnum.BILL_STATUS.code("生成"));
|
||||
mlmstCP.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
mlmstCP.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
mlmstCP.setCreate_time(DateUtil.now());
|
||||
mlmstCP.setIs_delete(false);
|
||||
// TODO 暂时写死
|
||||
mlmstCP.setSysdeptid("111");
|
||||
mlmstCP.setSyscompanyid("111");
|
||||
|
||||
mlmstCP.setRemark(whereJson.getString("remark"));
|
||||
|
||||
return mlmstCP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.wms.storage_manage.productmanage.service.structIvt.dao.StIvtStructivtCp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -46,5 +47,5 @@ public interface IStIvtStructivtCpService extends IService<StIvtStructivtCp> {
|
||||
* 明细row
|
||||
* }
|
||||
*/
|
||||
List getStructIvt(JSONObject whereJson);
|
||||
List<Map> getStructIvt(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
@@ -17,6 +18,7 @@ import java.math.BigDecimal;
|
||||
* @since 2023-05-04
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("st_ivt_structivt_cp")
|
||||
public class StIvtStructivtCp implements Serializable {
|
||||
|
||||
@@ -28,10 +28,18 @@
|
||||
|
||||
<select id="getStructIvt" resultType="java.util.Map">
|
||||
SELECT
|
||||
ivt.*
|
||||
ivt.*,
|
||||
attr.sect_name,
|
||||
attr.struct_code,
|
||||
attr.storagevehicle_code,
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
unit.unit_name AS qty_unit_name
|
||||
FROM
|
||||
ST_IVT_StructIvt_CP ivt
|
||||
LEFT JOIN st_ivt_structattr attr ON ivt.struct_id = attr.struct_id
|
||||
LEFT JOIN md_me_materialbase mater ON ivt.material_id = mater.material_id
|
||||
LEFT JOIN md_pb_measureunit unit ON unit.measure_unit_id = mater.base_unit_id
|
||||
WHERE attr.lock_type = '0'
|
||||
<if test="stor_id != null and stor_id != ''">
|
||||
and attr.stor_id = #{stor_id}
|
||||
@@ -45,6 +53,11 @@
|
||||
<if test="sale_id != null and sale_id != ''">
|
||||
and ivt.sale_id = #{sale_id}
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
and attr.struct_code LIKE #{remark} OR
|
||||
(attr.struct_name LIKE #{remark}) OR
|
||||
(attr.storagevehicle_code LIKE #{remark})
|
||||
</if>
|
||||
order by ivt.canuse_qty ASC,ivt.struct_code ASC
|
||||
|
||||
</select>
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -87,7 +88,7 @@ public class StIvtStructivtCpServiceImpl extends ServiceImpl<StIvtStructivtCpMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getStructIvt(JSONObject whereJson) {
|
||||
public List<Map> getStructIvt(JSONObject whereJson) {
|
||||
return baseMapper.getStructIvt(whereJson);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user