add:新增半成品盘点功能
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
package org.nl.wms.storage_manage.semimanage.controller.check;
|
||||
|
||||
|
||||
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.semimanage.service.check.dto.CheckQuery;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.IStIvtCheckmstBcpService;
|
||||
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,81 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @since 2023-05-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/stIvtCheckmstBcp")
|
||||
@RequestMapping("/api/bcp/check")
|
||||
public class StIvtCheckmstBcpController {
|
||||
|
||||
@Autowired
|
||||
private IStIvtCheckmstBcpService checkmstBcpService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询原料入库单")
|
||||
@ApiOperation("查询原料入库单")
|
||||
public ResponseEntity<Object> query(CheckQuery query, PageQuery page) {
|
||||
return new ResponseEntity<>(checkmstBcpService.pageQuery(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("创建盘点单")
|
||||
@ApiOperation("创建盘点单")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject whereJson) {
|
||||
checkmstBcpService.create(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getCheckDtl")
|
||||
@Log("查询盘点明细")
|
||||
@ApiOperation("查询盘点明细")
|
||||
public ResponseEntity<Object> getCheckDtl(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(checkmstBcpService.getCheckDtl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Log("修改盘点单")
|
||||
@ApiOperation("修改盘点单")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson) {
|
||||
checkmstBcpService.update(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@Log("删除入库单")
|
||||
@ApiOperation("删除入库单")
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids){
|
||||
checkmstBcpService.delete(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/saveCheck")
|
||||
@Log("盘点保存")
|
||||
@ApiOperation("盘点保存")
|
||||
public ResponseEntity<Object> saveCheck(@RequestBody JSONObject whereJson) {
|
||||
checkmstBcpService.saveCheck(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/confirm")
|
||||
@Log("移库单强制确认")
|
||||
@ApiOperation("移库单强制确认")
|
||||
public ResponseEntity<Object> confirm(@RequestBody JSONObject whereJson) {
|
||||
checkmstBcpService.confirm(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/process1")
|
||||
@Log("实盘为准,生成损溢单修改库存")
|
||||
@ApiOperation("实盘为准,生成损溢单修改库存")
|
||||
public ResponseEntity<Object> process1(@RequestBody JSONObject whereJson) {
|
||||
checkmstBcpService.process1(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/process0")
|
||||
@Log("账务为准")
|
||||
@ApiOperation("账务为准")
|
||||
public ResponseEntity<Object> process0(@RequestBody JSONObject whereJson) {
|
||||
checkmstBcpService.process0(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.check;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.check.dao.StIvtCheckmstYl;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckdtlBcp;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckmstBcp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +20,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IStIvtCheckdtlBcpService extends IService<StIvtCheckdtlBcp> {
|
||||
|
||||
/**
|
||||
* 主单据使用
|
||||
* @param row
|
||||
* @param mst
|
||||
* @return
|
||||
*/
|
||||
double create(JSONArray row, StIvtCheckmstBcp mst);
|
||||
|
||||
List<Map> getCheckDtl(JSONObject map);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.check;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dto.CheckQuery;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckmstBcp;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 盘点单主表 服务类
|
||||
@@ -13,4 +19,33 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IStIvtCheckmstBcpService extends IService<StIvtCheckmstBcp> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param query,page /
|
||||
* @return JSONObject
|
||||
*/
|
||||
Object pageQuery(CheckQuery query, PageQuery page);
|
||||
|
||||
void create(JSONObject jo);
|
||||
|
||||
List<Map> getCheckDtl(JSONObject map);
|
||||
|
||||
void update(JSONObject map);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param ids
|
||||
* {
|
||||
* 主表id..
|
||||
* }
|
||||
*/
|
||||
void delete(Long[] ids);
|
||||
|
||||
void saveCheck(JSONObject jo);
|
||||
|
||||
void confirm(JSONObject jo);
|
||||
|
||||
void process0(JSONObject jo);
|
||||
|
||||
void process1(JSONObject jo);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.check.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;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 盘点单明细表
|
||||
@@ -25,6 +26,7 @@ public class StIvtCheckdtlBcp implements Serializable {
|
||||
/**
|
||||
* 盘点单明细id
|
||||
*/
|
||||
@TableId
|
||||
private String checkdtl_id;
|
||||
|
||||
/**
|
||||
@@ -115,7 +117,7 @@ public class StIvtCheckdtlBcp implements Serializable {
|
||||
/**
|
||||
* 盘点结果
|
||||
*/
|
||||
private Boolean check_result;
|
||||
private String check_result;
|
||||
|
||||
/**
|
||||
* 盘点人
|
||||
@@ -130,7 +132,7 @@ public class StIvtCheckdtlBcp implements Serializable {
|
||||
/**
|
||||
* 盘点时间
|
||||
*/
|
||||
private Date check_time;
|
||||
private String check_time;
|
||||
|
||||
/**
|
||||
* 异常是否处理
|
||||
@@ -150,7 +152,7 @@ public class StIvtCheckdtlBcp implements Serializable {
|
||||
/**
|
||||
* 处理时间
|
||||
*/
|
||||
private Date process_time;
|
||||
private String process_time;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.check.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;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 盘点单主表
|
||||
@@ -25,6 +26,7 @@ public class StIvtCheckmstBcp implements Serializable {
|
||||
/**
|
||||
* 盘点单标识
|
||||
*/
|
||||
@TableId
|
||||
private String check_id;
|
||||
|
||||
/**
|
||||
@@ -75,7 +77,7 @@ public class StIvtCheckmstBcp implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date create_time;
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 审核人
|
||||
@@ -90,7 +92,7 @@ public class StIvtCheckmstBcp implements Serializable {
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date audit_time;
|
||||
private String audit_time;
|
||||
|
||||
/**
|
||||
* 确认人
|
||||
@@ -105,7 +107,7 @@ public class StIvtCheckmstBcp implements Serializable {
|
||||
/**
|
||||
* 确认时间
|
||||
*/
|
||||
private Date confirm_time;
|
||||
private String confirm_time;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
@@ -145,7 +147,7 @@ public class StIvtCheckmstBcp implements Serializable {
|
||||
/**
|
||||
* 回传时间
|
||||
*/
|
||||
private Date upload_time;
|
||||
private String upload_time;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
@@ -160,7 +162,7 @@ public class StIvtCheckmstBcp implements Serializable {
|
||||
/**
|
||||
* 车间标识
|
||||
*/
|
||||
private String product_area;
|
||||
private String workshop_id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.check.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckdtlBcp;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 盘点单明细表 Mapper 接口
|
||||
@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface StIvtCheckdtlBcpMapper extends BaseMapper<StIvtCheckdtlBcp> {
|
||||
|
||||
List<Map> getCheckDtl(@Param("map") Map map);
|
||||
}
|
||||
|
||||
@@ -2,4 +2,37 @@
|
||||
<!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.check.dao.mapper.StIvtCheckdtlBcpMapper">
|
||||
|
||||
<select id="getCheckDtl" resultType="java.util.Map">
|
||||
SELECT
|
||||
CheckDtl.*,
|
||||
struct.struct_code,
|
||||
struct.sect_code,
|
||||
mb.material_code,
|
||||
mb.material_name,
|
||||
user1.person_name AS process_optname
|
||||
FROM
|
||||
st_ivt_checkdtl_bcp CheckDtl
|
||||
LEFT JOIN md_me_materialbase mb ON mb.material_id = CheckDtl.material_id
|
||||
LEFT JOIN st_ivt_structattr struct ON struct.struct_id = CheckDtl.struct_id
|
||||
LEFT JOIN sys_user user1 ON user1.user_id = CheckDtl.process_optid
|
||||
<where>
|
||||
1=1
|
||||
<if test="map.check_id != '' and map.check_id != null">
|
||||
and CheckDtl.check_id = #{map.check_id}
|
||||
</if>
|
||||
<if test="map.checkdtl_id != '' and map.checkdtl_id != null">
|
||||
and CheckDtl.checkdtl_id = #{map.checkdtl_id}
|
||||
</if>
|
||||
<if test="map.status != '' and map.status != null">
|
||||
and #{map.status} >= CheckDtl.status
|
||||
</if>
|
||||
<if test="map.check_result != '' and map.check_result != null and map.check_result != '-1'">
|
||||
and #{map.check_result} = CheckDtl.check_result
|
||||
</if>
|
||||
<if test="map.check_result == '-1'">
|
||||
and CheckDtl.check_result IN ('1','2')
|
||||
</if>
|
||||
</where>
|
||||
order by CheckDtl.seq_no
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.check.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.common.domain.query.BaseQuery;
|
||||
import org.nl.common.domain.query.QParam;
|
||||
import org.nl.common.enums.QueryTEnum;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckmstBcp;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/4 19:49
|
||||
*/
|
||||
@Data
|
||||
public class CheckQuery extends BaseQuery<StIvtCheckmstBcp> {
|
||||
|
||||
|
||||
private String stor_id;
|
||||
|
||||
private String status;
|
||||
|
||||
private String check_type;
|
||||
|
||||
private String check_code;
|
||||
|
||||
private Boolean is_delete = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void paramMapping() {
|
||||
super.doP.put("check_code", QParam.builder().k(new String[]{"check_code"}).type(QueryTEnum.LK).build());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,31 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.check.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 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.CHECKEnum;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.check.dao.StIvtCheckdtlYl;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.check.dao.StIvtCheckmstYl;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckdtlBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckmstBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.mapper.StIvtCheckdtlBcpMapper;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.IStIvtCheckdtlBcpService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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,56 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class StIvtCheckdtlBcpServiceImpl extends ServiceImpl<StIvtCheckdtlBcpMapper, StIvtCheckdtlBcp> implements IStIvtCheckdtlBcpService {
|
||||
|
||||
@Autowired
|
||||
private IStIvtSectattrService sectattrService;
|
||||
@Autowired
|
||||
private IStIvtStructattrService structattrService;
|
||||
|
||||
@Override
|
||||
public double create(JSONArray rows, StIvtCheckmstBcp mst) {
|
||||
double total_qty = 0;
|
||||
|
||||
if (rows.size() > 0 && ObjectUtil.isNotEmpty(mst)) {
|
||||
// 先删除在插入
|
||||
this.remove(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", mst.getCheck_id()));
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
String checkdtl_id = IdUtil.getStringId();
|
||||
StIvtCheckdtlBcp row = rows.getJSONObject(i).toJavaObject(StIvtCheckdtlBcp.class);
|
||||
row.setCheckdtl_id(checkdtl_id);
|
||||
row.setCheck_id(mst.getCheck_id());
|
||||
row.setCheck_code(mst.getCheck_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(CHECKEnum.DTL_STATUS.code("生成"));
|
||||
this.save(row);
|
||||
|
||||
//锁定货位
|
||||
structattrService.update(new UpdateWrapper<StIvtStructattr>().set("lock_type", "1").set("inv_code",mst.getCheck_code()).eq("struct_id", row.getStruct_id()));
|
||||
}
|
||||
}
|
||||
return total_qty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getCheckDtl(JSONObject map) {
|
||||
return this.baseMapper.getCheckDtl(map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,46 @@
|
||||
package org.nl.wms.storage_manage.semimanage.service.check.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.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.rawmanage.service.check.dao.StIvtCheckdtlYl;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.check.dao.StIvtCheckmstYl;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckdtlBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dto.CheckQuery;
|
||||
import org.nl.wms.storage_manage.semimanage.MLEnum;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.IStIvtCheckdtlBcpService;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.IStIvtCheckmstBcpService;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.StIvtCheckmstBcp;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.dao.mapper.StIvtCheckmstBcpMapper;
|
||||
import org.nl.wms.storage_manage.semimanage.service.check.IStIvtCheckmstBcpService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.wms.storage_manage.semimanage.service.moveOrLess.IStIvtMoreorlessmstBcpService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 盘点单主表 服务实现类
|
||||
@@ -17,4 +52,324 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class StIvtCheckmstBcpServiceImpl extends ServiceImpl<StIvtCheckmstBcpMapper, StIvtCheckmstBcp> implements IStIvtCheckmstBcpService {
|
||||
|
||||
@Autowired
|
||||
private IStIvtBsrealstorattrService stIvtBsrealstorattrService;
|
||||
|
||||
@Autowired
|
||||
private IStIvtCheckdtlBcpService checkdtlBcpService;
|
||||
|
||||
@Autowired
|
||||
private IStIvtStructattrService structattrService;
|
||||
@Autowired
|
||||
private IStIvtMoreorlessmstBcpService moreorlessmstBcpService;
|
||||
|
||||
@Override
|
||||
public Object pageQuery(CheckQuery query, PageQuery page) {
|
||||
// 查询条件
|
||||
page.setSort("check_code");
|
||||
// 分页查询
|
||||
Page<StIvtCheckmstBcp> pageQuery = this.page(page.build(), query.build());
|
||||
TableDataInfo<StIvtCheckmstBcp> build = TableDataInfo.build(pageQuery);
|
||||
return build;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(JSONObject form) {
|
||||
JSONArray rows = form.getJSONArray("tableData");
|
||||
if (ObjectUtil.isEmpty(rows)) throw new BadRequestException("请求参数不能为空");
|
||||
|
||||
// 调用主表 插入/更新方法
|
||||
StIvtCheckmstBcp checkmstYl = packageMstForm(new StIvtCheckmstBcp(), form);
|
||||
this.save(checkmstYl);
|
||||
|
||||
//调用明细表 插入方法
|
||||
checkdtlBcpService.create(rows, checkmstYl);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getCheckDtl(JSONObject map) {
|
||||
return checkdtlBcpService.getCheckDtl(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(JSONObject form) {
|
||||
Assert.notNull(new Object[]{form, form.get("check_id")}, "请求参数不能为空");
|
||||
StIvtCheckmstBcp mst = form.toJavaObject(StIvtCheckmstBcp.class);
|
||||
this.updateById(mst);
|
||||
|
||||
JSONArray rows = form.getJSONArray("tableData");
|
||||
if (ObjectUtil.isEmpty(rows)) throw new BadRequestException("请求参数不能为空");
|
||||
// 调用明细表 插入/更新方法
|
||||
checkdtlBcpService.create(rows, mst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCheck(JSONObject whereJson) {
|
||||
JSONObject form = whereJson.getJSONObject("row");
|
||||
JSONArray rows = whereJson.getJSONArray("rows");
|
||||
|
||||
StIvtCheckmstBcp jo_mst = this.getOne(new QueryWrapper<StIvtCheckmstBcp>().eq("check_id", form.getString("check_id")).in("status", new String[]{"10", "30"}));
|
||||
if (jo_mst == null) {
|
||||
throw new BadRequestException("盘点单状态异常!");
|
||||
}
|
||||
checkdtlBcpService.remove(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", form.getString("check_id")).in("status", new String[]{"01", "04"}));
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject jo = rows.getJSONObject(i);
|
||||
String status = jo.getString("status");
|
||||
StIvtCheckdtlBcp dtl = jo.toJavaObject(StIvtCheckdtlBcp.class);
|
||||
double base_qty = jo.getDoubleValue("base_qty");
|
||||
dtl.setSeq_no(BigDecimal.valueOf(i + 1));
|
||||
//已盘点过的明细不再处理
|
||||
if ("05,06,07,99".contains(status)) {
|
||||
checkdtlBcpService.updateById(dtl);
|
||||
continue;
|
||||
}
|
||||
dtl.setStatus(CHECKEnum.DTL_STATUS.code("盘点中"));
|
||||
dtl.setCheck_optid(SecurityUtils.getCurrentUserId());
|
||||
dtl.setCheck_optname(SecurityUtils.getCurrentNickName());
|
||||
dtl.setCheck_time(DateUtil.now());
|
||||
double fac_qty = jo.getDoubleValue("fac_qty");
|
||||
//判断盈亏
|
||||
if (fac_qty > base_qty) {
|
||||
dtl.setCheck_result("2");
|
||||
} else if (fac_qty < base_qty) {
|
||||
dtl.setCheck_result("1");
|
||||
} else {
|
||||
dtl.setCheck_result("0");
|
||||
}
|
||||
if (StrUtil.isEmpty(jo.getString("checkdtl_id"))) {
|
||||
jo.put("checkdtl_id", IdUtil.getStringId());
|
||||
}
|
||||
checkdtlBcpService.save(dtl);
|
||||
}
|
||||
jo_mst.setDtl_num(BigDecimal.valueOf(rows.size()));
|
||||
jo_mst.setStatus(CHECKEnum.BILL_STATUS.code("盘点中"));
|
||||
jo_mst.setIs_nok(false);
|
||||
List<StIvtCheckdtlBcp> dtl_list = checkdtlBcpService.list(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", form.getString("check_id")).ne("check_result", "0"));
|
||||
if (dtl_list.size() != 0) {
|
||||
jo_mst.setIs_nok(true);
|
||||
}
|
||||
this.updateById(jo_mst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirm(JSONObject whereJson) {
|
||||
|
||||
JSONObject form = whereJson.getJSONObject("row");
|
||||
JSONArray rows = whereJson.getJSONArray("rows");
|
||||
|
||||
StIvtCheckmstBcp jo_mst = this.getOne(new QueryWrapper<StIvtCheckmstBcp>().eq("check_id", form.getString("check_id")).in("status", new String[]{"10", "30"}));
|
||||
if (jo_mst == null) {
|
||||
throw new BadRequestException("盘点单状态异常!");
|
||||
}
|
||||
checkdtlBcpService.remove(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", form.getString("check_id")).in("status", new String[]{"01", "04"}));
|
||||
//定义需要需要更新的的点位集合
|
||||
HashSet<String> set = new HashSet<>();
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject jo = rows.getJSONObject(i);
|
||||
String status = jo.getString("status");
|
||||
StIvtCheckdtlBcp dtl = jo.toJavaObject(StIvtCheckdtlBcp.class);
|
||||
double base_qty = jo.getDoubleValue("base_qty");
|
||||
dtl.setSeq_no(BigDecimal.valueOf(i + 1));
|
||||
//已盘点过的明细不再处理
|
||||
if ("05,06,07,99".contains(status)) {
|
||||
checkdtlBcpService.updateById(dtl);
|
||||
continue;
|
||||
}
|
||||
dtl.setStatus(CHECKEnum.DTL_STATUS.code("已盘点"));
|
||||
dtl.setCheck_optid(SecurityUtils.getCurrentUserId());
|
||||
dtl.setCheck_optname(SecurityUtils.getCurrentNickName());
|
||||
dtl.setCheck_time(DateUtil.now());
|
||||
double fac_qty = jo.getDoubleValue("fac_qty");
|
||||
//判断盈亏
|
||||
if (fac_qty > base_qty) {
|
||||
dtl.setCheck_result("2");
|
||||
} else if (fac_qty < base_qty) {
|
||||
dtl.setCheck_result("1");
|
||||
} else {
|
||||
dtl.setCheck_result("0");
|
||||
dtl.setStatus(CHECKEnum.DTL_STATUS.code("确认完成"));
|
||||
}
|
||||
if (StrUtil.isEmpty(jo.getString("checkdtl_id"))) {
|
||||
jo.put("checkdtl_id", IdUtil.getStringId());
|
||||
}
|
||||
checkdtlBcpService.save(dtl);
|
||||
set.add(dtl.getStruct_id());
|
||||
}
|
||||
jo_mst.setDtl_num(BigDecimal.valueOf(rows.size()));
|
||||
|
||||
jo_mst.setIs_nok(false);
|
||||
List<StIvtCheckdtlBcp> dtl_list = checkdtlBcpService.list(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", form.getString("check_id")).ne("check_result", "0"));
|
||||
if (dtl_list.size() != 0) {
|
||||
jo_mst.setIs_nok(true);
|
||||
}
|
||||
jo_mst.setStatus(CHECKEnum.BILL_STATUS.code("盘点中"));
|
||||
List<StIvtCheckdtlBcp> finish_list = checkdtlBcpService.list(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", form.getString("check_id")).in("status", new String[]{"99", "07"}));
|
||||
//说明全部确认
|
||||
if (finish_list.size() == jo_mst.getDtl_num().intValue()) {
|
||||
checkdtlBcpService.update(new UpdateWrapper<StIvtCheckdtlBcp>().set("status", "99").eq("check_id", form.getString("check_id")));
|
||||
|
||||
jo_mst.setStatus(CHECKEnum.BILL_STATUS.code("完成"));
|
||||
jo_mst.setConfirm_optid(SecurityUtils.getCurrentUserId());
|
||||
jo_mst.setConfirm_optname(SecurityUtils.getCurrentNickName());
|
||||
jo_mst.setConfirm_time(DateUtil.now());
|
||||
//锁定起点点位、仓位
|
||||
set.forEach(struct_id -> structattrService.update(new UpdateWrapper<StIvtStructattr>().set("lock_type", "0").set("inv_code", "").eq("struct_id", struct_id)));
|
||||
}
|
||||
this.updateById(jo_mst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process0(JSONObject whereJson) {
|
||||
JSONObject form = whereJson.getJSONObject("form");
|
||||
JSONObject row = whereJson.getJSONObject("row");
|
||||
|
||||
StIvtCheckmstBcp jo_mst = this.getOne(new QueryWrapper<StIvtCheckmstBcp>().eq("check_id", form.getString("check_id")).ne("status", "99"));
|
||||
if (jo_mst == null) {
|
||||
throw new BadRequestException("盘点单状态异常!");
|
||||
}
|
||||
StIvtCheckdtlBcp dtl = row.toJavaObject(StIvtCheckdtlBcp.class);
|
||||
dtl.setStatus(CHECKEnum.DTL_STATUS.code("确认完成"));
|
||||
dtl.setProcess_optid(SecurityUtils.getCurrentUserId());
|
||||
dtl.setProcess_time(DateUtil.now());
|
||||
dtl.setProcess_type(CHECKEnum.PROCESS_TYPE.code("账务为准"));
|
||||
dtl.setIs_process(true);
|
||||
checkdtlBcpService.updateById(dtl);
|
||||
List<StIvtCheckdtlBcp> finish_list = checkdtlBcpService.list(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", form.getString("check_id")).in("status", new String[]{"99", "07"}));
|
||||
//说明全部确认
|
||||
if (finish_list.size() == jo_mst.getDtl_num().intValue()) {
|
||||
checkdtlBcpService.update(new UpdateWrapper<StIvtCheckdtlBcp>().set("status", "99").eq("check_id", form.getString("check_id")));
|
||||
|
||||
jo_mst.setStatus(CHECKEnum.BILL_STATUS.code("完成"));
|
||||
jo_mst.setConfirm_optid(SecurityUtils.getCurrentUserId());
|
||||
jo_mst.setConfirm_optname(SecurityUtils.getCurrentNickName());
|
||||
jo_mst.setConfirm_time(DateUtil.now());
|
||||
//解锁起点点位、仓位
|
||||
finish_list.stream()
|
||||
.map(finish -> finish.getStruct_id())
|
||||
.distinct()
|
||||
.forEach(struct_id -> structattrService.update(new UpdateWrapper<StIvtStructattr>().set("inv_code", "").set("lock_type", "0").eq("struct_id", struct_id)));
|
||||
}
|
||||
this.updateById(jo_mst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process1(JSONObject whereJson) {
|
||||
JSONObject form = whereJson.getJSONObject("form");
|
||||
JSONObject row = whereJson.getJSONObject("row");
|
||||
|
||||
StIvtCheckmstBcp jo_mst = this.getOne(new QueryWrapper<StIvtCheckmstBcp>().eq("check_id", form.getString("check_id")).ne("status", "99"));
|
||||
StIvtCheckdtlBcp dtl = row.toJavaObject(StIvtCheckdtlBcp.class);
|
||||
if (jo_mst == null) {
|
||||
throw new BadRequestException("盘点单状态异常!");
|
||||
}
|
||||
|
||||
//创建损溢单
|
||||
JSONObject mol_jo = new JSONObject();
|
||||
mol_jo.put("buss_type", MLEnum.BILL_TYPE.code("盘点损溢"));
|
||||
if (row.getString("check_result").equals("1")) {
|
||||
mol_jo.put("mol_type", MLEnum.MOL_TYPE.code("损"));
|
||||
} else {
|
||||
mol_jo.put("mol_type", MLEnum.MOL_TYPE.code("溢"));
|
||||
}
|
||||
mol_jo.put("stor_id", jo_mst.getStor_id());
|
||||
mol_jo.put("remark", "盘点单:" + jo_mst.getCheck_code() + "生成的损溢单");
|
||||
mol_jo.put("workshop_id", jo_mst.getWorkshop_id());
|
||||
|
||||
//创建明细
|
||||
JSONObject dtl_jo = new JSONObject();
|
||||
dtl_jo.put("sect_id", dtl.getSect_id());
|
||||
dtl_jo.put("material_id", dtl.getMaterial_id());
|
||||
dtl_jo.put("struct_id", dtl.getStruct_id());
|
||||
dtl_jo.put("qty_unit_id", dtl.getQty_unit_id());
|
||||
dtl_jo.put("qty_unit_name", dtl.getQty_unit_name());
|
||||
dtl_jo.put("mol_qty", row.getString("check_result").equals("1") ? NumberUtil.sub(dtl.getBase_qty(), dtl.getFac_qty()) : NumberUtil.sub(dtl.getFac_qty(), dtl.getBase_qty()));
|
||||
dtl_jo.put("source_billdtl_id", dtl.getCheckdtl_id());
|
||||
dtl_jo.put("source_bill_type", jo_mst.getCheck_type());
|
||||
dtl_jo.put("source_bill_code", jo_mst.getCheck_code());
|
||||
dtl_jo.put("source_bill_table", "ST_IVT_CheckMst_YL");
|
||||
JSONArray mol_rows = new JSONArray();
|
||||
mol_rows.add(dtl_jo);
|
||||
mol_jo.put("tableData", mol_rows);
|
||||
mol_jo.put("auto_confirm", "1");
|
||||
//创建损溢单
|
||||
//moreorlessmstBcpService.create(mol_jo);
|
||||
|
||||
|
||||
dtl.setStatus(CHECKEnum.DTL_STATUS.code("确认完成"));
|
||||
dtl.setProcess_optid(SecurityUtils.getCurrentUserId());
|
||||
dtl.setProcess_time(DateUtil.now());
|
||||
dtl.setProcess_type(CHECKEnum.PROCESS_TYPE.code("实盘为准"));
|
||||
dtl.setIs_process(true);
|
||||
checkdtlBcpService.updateById(dtl);
|
||||
List<StIvtCheckdtlBcp> finish_list = checkdtlBcpService.list(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", form.getString("check_id")).in("status", new String[]{"99", "07"}));
|
||||
//说明全部确认
|
||||
if (finish_list.size() == jo_mst.getDtl_num().intValue()) {
|
||||
checkdtlBcpService.update(new UpdateWrapper<StIvtCheckdtlBcp>().set("status", "99").eq("check_id", form.getString("check_id")));
|
||||
|
||||
jo_mst.setStatus(CHECKEnum.BILL_STATUS.code("完成"));
|
||||
jo_mst.setConfirm_optid(SecurityUtils.getCurrentUserId());
|
||||
jo_mst.setConfirm_optname(SecurityUtils.getCurrentNickName());
|
||||
jo_mst.setConfirm_time(DateUtil.now());
|
||||
//解锁起点点位、仓位
|
||||
finish_list.stream()
|
||||
.map(finish -> finish.getStruct_id())
|
||||
.distinct()
|
||||
.forEach(struct_id -> structattrService.update(new UpdateWrapper<StIvtStructattr>().set("inv_code", "").set("lock_type", "0").eq("struct_id", struct_id)));
|
||||
}
|
||||
this.updateById(jo_mst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
StIvtCheckmstBcp dao = this.getOne(new QueryWrapper<StIvtCheckmstBcp>().eq("check_id", id));
|
||||
dao.setIs_delete(true);
|
||||
|
||||
//获取所有明细下的仓位解锁
|
||||
List<StIvtCheckdtlBcp> dtl_list = checkdtlBcpService.list(new QueryWrapper<StIvtCheckdtlBcp>().eq("check_id", id));
|
||||
dtl_list.stream()
|
||||
.map(dtl -> dtl.getStruct_id())
|
||||
.distinct()
|
||||
.forEach(struct_id -> structattrService.update(new UpdateWrapper<StIvtStructattr>().set("inv_code", "").set("lock_type", "0").eq("struct_id", struct_id)));
|
||||
this.updateById(dao);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private StIvtCheckmstBcp packageMstForm(StIvtCheckmstBcp checkmstYl, JSONObject whereJson) {
|
||||
JSONArray rows = whereJson.getJSONArray("tableData");
|
||||
// 新增
|
||||
checkmstYl.setCheck_id(IdUtil.getStringId());
|
||||
checkmstYl.setCheck_code(CodeUtil.getNewCode("PD_CODE"));
|
||||
checkmstYl.setBuss_type(whereJson.getString("check_type"));
|
||||
checkmstYl.setCheck_type(checkmstYl.getBuss_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("仓库不存在或未启用!");
|
||||
|
||||
checkmstYl.setStor_id(bsrealDao.getStor_id());
|
||||
checkmstYl.setStor_name(bsrealDao.getStor_name());
|
||||
checkmstYl.setDtl_num(BigDecimal.valueOf(rows.size()));
|
||||
checkmstYl.setCreate_mode(CHECKEnum.CREATE_MODE.code("PC产生"));
|
||||
checkmstYl.setStatus(CHECKEnum.BILL_STATUS.code("生成"));
|
||||
checkmstYl.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
checkmstYl.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
checkmstYl.setCreate_time(DateUtil.now());
|
||||
checkmstYl.setIs_delete(false);
|
||||
checkmstYl.setIs_upload(true);
|
||||
// TODO 暂时写死
|
||||
checkmstYl.setSysdeptid("111");
|
||||
checkmstYl.setSyscompanyid("111");
|
||||
|
||||
checkmstYl.setRemark(whereJson.getString("remark"));
|
||||
checkmstYl.setWorkshop_id(whereJson.getString("workshop_id"));
|
||||
|
||||
return checkmstYl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,18 @@ public class StIvtShutframeinvBcpServiceImpl extends ServiceImpl<StIvtShutframei
|
||||
in_ivt.setCanuse_qty(NumberUtil.add(in_ivt.getCanuse_qty(), dtl.getFact_qty()));
|
||||
structivtBcpService.remove(new QueryWrapper<StIvtStructivtBcp>().eq("struct_id", turnout_struct_id));
|
||||
structivtBcpService.updateById(in_ivt);
|
||||
|
||||
dtl.setWork_status(SHUTEnum.WORK_STATUS.code("完成"));
|
||||
shutframedtlBcpService.updateById(dtl);
|
||||
});
|
||||
|
||||
StIvtShutframeinvBcp mst = this.getById(form.getString("shutframeinv_id"));
|
||||
mst.setConfirm_optid(SecurityUtils.getCurrentUserId());
|
||||
mst.setConfirm_optname(SecurityUtils.getCurrentNickName());
|
||||
mst.setConfirm_time(DateUtil.now());
|
||||
mst.setBill_status(SHUTEnum.BILL_STATUS.code("完成"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user