初步完善盘点

This commit is contained in:
liumingxiy 2024-11-13 17:53:21 +08:00
parent b05fa24c5d
commit 15fd353d5a
9 changed files with 251 additions and 43 deletions

View File

@ -19,7 +19,7 @@ import java.util.List;
* 盘点计划Controller
*
* @author yinjinlu
* @date 2024-11-12
* @date 2024-11-13
*/
@RestController
@RequestMapping("/md/WMS_INVENTORY_PLAN")
@ -66,6 +66,7 @@ public class WmsInventoryPlanController extends BaseController {
@Log(title = "盘点计划", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WmsInventoryPlan wmsInventoryPlan) {
wmsInventoryPlan.setCreateBy(getUsername());
return toAjax(wmsInventoryPlanService.insertWmsInventoryPlan(wmsInventoryPlan));
}
@ -76,6 +77,7 @@ public class WmsInventoryPlanController extends BaseController {
@Log(title = "盘点计划", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WmsInventoryPlan wmsInventoryPlan) {
wmsInventoryPlan.setUpdateBy(getUsername());
return toAjax(wmsInventoryPlanService.updateWmsInventoryPlan(wmsInventoryPlan));
}

View File

@ -6,12 +6,13 @@ import com.ktg.common.core.domain.BaseEntity;
import com.ktg.mes.wm.domain.WmWarehouse;
import java.util.Date;
import java.util.List;
/**
* 盘点计划对象 WMS_INVENTORY_PLAN
*
* @author yinjinlu
* @date 2024-11-12
* @date 2024-11-13
*/
public class WmsInventoryPlan extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -105,126 +106,139 @@ public class WmsInventoryPlan extends BaseEntity {
private WmWarehouse mWarehouse;
public Long getWmsStockPlanId() {
return wmsStockPlanId;
}
/**
* 盘点信息
*/
private List<WmsInventory> wmsInventoryList;
public void setWmsStockPlanId(Long wmsStockPlanId) {
this.wmsStockPlanId = wmsStockPlanId;
}
public Long getWmsInventoryConfigureId() {
return wmsInventoryConfigureId;
public Long getWmsStockPlanId() {
return wmsStockPlanId;
}
public void setWmsInventoryConfigureId(Long wmsInventoryConfigureId) {
this.wmsInventoryConfigureId = wmsInventoryConfigureId;
}
public String getPlanCode() {
return planCode;
public Long getWmsInventoryConfigureId() {
return wmsInventoryConfigureId;
}
public void setPlanCode(String planCode) {
this.planCode = planCode;
}
public String getPlanName() {
return planName;
public String getPlanCode() {
return planCode;
}
public void setPlanName(String planName) {
this.planName = planName;
}
public String getDataType() {
return dataType;
public String getPlanName() {
return planName;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public Long getmWarehouseId() {
return mWarehouseId;
public String getDataType() {
return dataType;
}
public void setmWarehouseId(Long mWarehouseId) {
this.mWarehouseId = mWarehouseId;
}
public Date getBeginTime() {
return beginTime;
public Long getmWarehouseId() {
return mWarehouseId;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
public Date getBeginTime() {
return beginTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public String getIsag() {
return isag;
public Date getEndTime() {
return endTime;
}
public void setIsag(String isag) {
this.isag = isag;
}
public String getStatus() {
return status;
public String getIsag() {
return isag;
}
public void setStatus(String status) {
this.status = status;
}
public String getDescription() {
return description;
public String getStatus() {
return status;
}
public void setDescription(String description) {
this.description = description;
}
public String getAttr1() {
return attr1;
public String getDescription() {
return description;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr2() {
return attr2;
public String getAttr1() {
return attr1;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getAttr3() {
return attr3;
public String getAttr2() {
return attr2;
}
public void setAttr3(String attr3) {
this.attr3 = attr3;
}
public String getAttr4() {
return attr4;
public String getAttr3() {
return attr3;
}
public void setAttr4(String attr4) {
this.attr4 = attr4;
}
public String getAttr4() {
return attr4;
}
public List<WmsInventory> getWmsInventoryList() {
return wmsInventoryList;
}
public void setWmsInventoryList(List<WmsInventory> wmsInventoryList) {
this.wmsInventoryList = wmsInventoryList;
}
public WmWarehouse getmWarehouse() {
return mWarehouse;
}
@ -252,6 +266,7 @@ public class WmsInventoryPlan extends BaseEntity {
", attr3='" + attr3 + '\'' +
", attr4='" + attr4 + '\'' +
", mWarehouse=" + mWarehouse +
", wmsInventoryList=" + wmsInventoryList +
'}';
}
}

View File

@ -1,5 +1,6 @@
package com.ktg.mes.md.mapper;
import com.ktg.mes.md.domain.WmsInventory;
import com.ktg.mes.md.domain.WmsInventoryPlan;
import java.util.List;
@ -8,7 +9,7 @@ import java.util.List;
* 盘点计划Mapper接口
*
* @author yinjinlu
* @date 2024-11-12
* @date 2024-11-13
*/
public interface WmsInventoryPlanMapper {
/**
@ -58,4 +59,29 @@ public interface WmsInventoryPlanMapper {
* @return 结果
*/
public int deleteWmsInventoryPlanByWmsStockPlanIds(Long[] wmsStockPlanIds);
/**
* 批量删除盘点
*
* @param wmsStockPlanIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteWmsInventoryByWmsStockPlanIds(Long[] wmsStockPlanIds);
/**
* 批量新增盘点
*
* @param wmsInventoryList 盘点列表
* @return 结果
*/
public int batchWmsInventory(List<WmsInventory> wmsInventoryList);
/**
* 通过盘点计划主键删除盘点信息
*
* @param wmsStockPlanId 盘点计划ID
* @return 结果
*/
public int deleteWmsInventoryByWmsStockPlanId(Long wmsStockPlanId);
}

View File

@ -8,7 +8,7 @@ import java.util.List;
* 盘点计划Service接口
*
* @author yinjinlu
* @date 2024-11-12
* @date 2024-11-13
*/
public interface IWmsInventoryPlanService {
/**

View File

@ -160,7 +160,7 @@ public class WmsInventoryConfigureServiceImpl implements IWmsInventoryConfigureS
wmsInventoryPlan.setBeginTime(startTime);
wmsInventoryPlan.setEndTime(endTime);
wmsInventoryPlan.setStatus("STATUS_1");
wmsInventoryPlan.setDescription(String.format("%s动生成的盘点计划。", new SimpleDateFormat("yyyy年MM月dd日").format(nowDate)));
wmsInventoryPlan.setDescription(String.format("%s动生成的盘点计划。", new SimpleDateFormat("yyyy年MM月dd日").format(nowDate)));
wmsInventoryPlan.setIsag("N");
wmsInventoryPlan.setCreateTime(nowDate);

View File

@ -1,29 +1,50 @@
package com.ktg.mes.md.service.impl;
import com.ktg.common.utils.DateUtils;
import com.ktg.common.utils.StringUtils;
import com.ktg.mes.md.domain.WmsInventory;
import com.ktg.mes.md.domain.WmsInventoryPlan;
import com.ktg.mes.md.mapper.MdItemMapper;
import com.ktg.mes.md.mapper.MdUnitMeasureMapper;
import com.ktg.mes.md.mapper.WmsInventoryMapper;
import com.ktg.mes.md.mapper.WmsInventoryPlanMapper;
import com.ktg.mes.md.service.IWmsInventoryPlanService;
import com.ktg.mes.wm.mapper.WmStorageAreaMapper;
import com.ktg.mes.wm.mapper.WmWarehouseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 盘点计划Service业务层处理
*
* @author yinjinlu
* @date 2024-11-12
* @date 2024-11-13
*/
@Service
public class WmsInventoryPlanServiceImpl implements IWmsInventoryPlanService {
@Autowired
private WmsInventoryMapper wmsInventoryMapper;
@Autowired
private WmsInventoryPlanMapper wmsInventoryPlanMapper;
@Autowired
private WmWarehouseMapper wmWarehouseMapper;
@Autowired
private WmStorageAreaMapper wmStorageAreaMapper;
@Autowired
private MdItemMapper mdItemMapper;
@Autowired
private MdUnitMeasureMapper mdUnitMeasureMapper;
/**
* 查询盘点计划
*
@ -34,6 +55,13 @@ public class WmsInventoryPlanServiceImpl implements IWmsInventoryPlanService {
public WmsInventoryPlan selectWmsInventoryPlanByWmsStockPlanId(Long wmsStockPlanId) {
WmsInventoryPlan wmsInventoryPlan = wmsInventoryPlanMapper.selectWmsInventoryPlanByWmsStockPlanId(wmsStockPlanId);
wmsInventoryPlan.setmWarehouse(wmWarehouseMapper.selectWmWarehouseByWarehouseId(wmsInventoryPlan.getmWarehouseId()));
wmsInventoryPlan.getWmsInventoryList().forEach(item -> {
item.setWmsStockPlan(wmsInventoryPlanMapper.selectWmsInventoryPlanByWmsStockPlanId(item.getWmsStockPlanId()));
item.setmWarehouse(wmWarehouseMapper.selectWmWarehouseByWarehouseId(item.getmWarehouseId()));
item.setArea(wmStorageAreaMapper.selectWmStorageAreaByAreaId(item.getAreaId()));
item.setMdItem(mdItemMapper.selectMdItemById(item.getMdItemId()));
item.setUnit(mdUnitMeasureMapper.selectMdUnitMeasureByMeasureId(item.getUnitId()));
});
return wmsInventoryPlan;
}
@ -58,10 +86,13 @@ public class WmsInventoryPlanServiceImpl implements IWmsInventoryPlanService {
* @param wmsInventoryPlan 盘点计划
* @return 结果
*/
@Transactional
@Override
public int insertWmsInventoryPlan(WmsInventoryPlan wmsInventoryPlan) {
wmsInventoryPlan.setCreateTime(DateUtils.getNowDate());
return wmsInventoryPlanMapper.insertWmsInventoryPlan(wmsInventoryPlan);
int rows = wmsInventoryPlanMapper.insertWmsInventoryPlan(wmsInventoryPlan);
insertWmsInventory(wmsInventoryPlan);
return rows;
}
/**
@ -70,9 +101,22 @@ public class WmsInventoryPlanServiceImpl implements IWmsInventoryPlanService {
* @param wmsInventoryPlan 盘点计划
* @return 结果
*/
@Transactional
@Override
public int updateWmsInventoryPlan(WmsInventoryPlan wmsInventoryPlan) {
wmsInventoryPlan.setUpdateTime(DateUtils.getNowDate());
wmsInventoryPlan.getWmsInventoryList().forEach(wmsInventory -> {
wmsInventory.setUpdateTime(DateUtils.getNowDate());
if (wmsInventory.getInventoryCount() != null && wmsInventory.getInventoryCount() != 0) {
wmsInventory.setInventoryTime(new Date(System.currentTimeMillis()));
wmsInventory.setDiffCount(Math.abs(wmsInventory.getSystemCount() - wmsInventory.getInventoryCount()));
}
if (wmsInventory.getAgCount() != null && wmsInventory.getAgCount() != 0) {
wmsInventory.setAgTime(new Date(System.currentTimeMillis()));
wmsInventory.setDiffCount(Math.abs(wmsInventory.getSystemCount() - wmsInventory.getAgCount()));
}
wmsInventoryMapper.updateWmsInventory(wmsInventory);
});
return wmsInventoryPlanMapper.updateWmsInventoryPlan(wmsInventoryPlan);
}
@ -82,8 +126,10 @@ public class WmsInventoryPlanServiceImpl implements IWmsInventoryPlanService {
* @param wmsStockPlanIds 需要删除的盘点计划主键
* @return 结果
*/
@Transactional
@Override
public int deleteWmsInventoryPlanByWmsStockPlanIds(Long[] wmsStockPlanIds) {
wmsInventoryPlanMapper.deleteWmsInventoryByWmsStockPlanIds(wmsStockPlanIds);
return wmsInventoryPlanMapper.deleteWmsInventoryPlanByWmsStockPlanIds(wmsStockPlanIds);
}
@ -93,8 +139,30 @@ public class WmsInventoryPlanServiceImpl implements IWmsInventoryPlanService {
* @param wmsStockPlanId 盘点计划主键
* @return 结果
*/
@Transactional
@Override
public int deleteWmsInventoryPlanByWmsStockPlanId(Long wmsStockPlanId) {
wmsInventoryPlanMapper.deleteWmsInventoryByWmsStockPlanId(wmsStockPlanId);
return wmsInventoryPlanMapper.deleteWmsInventoryPlanByWmsStockPlanId(wmsStockPlanId);
}
/**
* 新增盘点信息
*
* @param wmsInventoryPlan 盘点计划对象
*/
public void insertWmsInventory(WmsInventoryPlan wmsInventoryPlan) {
List<WmsInventory> wmsInventoryList = wmsInventoryPlan.getWmsInventoryList();
Long wmsStockPlanId = wmsInventoryPlan.getWmsStockPlanId();
if (StringUtils.isNotNull(wmsInventoryList)) {
List<WmsInventory> list = new ArrayList<WmsInventory>();
for (WmsInventory wmsInventory : wmsInventoryList) {
wmsInventory.setWmsStockPlanId(wmsStockPlanId);
list.add(wmsInventory);
}
if (list.size() > 0) {
wmsInventoryPlanMapper.batchWmsInventory(list);
}
}
}
}

View File

@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''"> and UPDATE_BY = #{updateBy}</if>
<if test="updateTime != null "> and UPDATE_TIME = #{updateTime}</if>
</where>
ORDER BY CREATE_TIME DESC
</select>
<select id="selectWmsInventoryConfigureByWmsInventoryConfigureId" parameterType="Long" resultMap="WmsInventoryConfigureResult">

View File

@ -70,6 +70,7 @@
<if test="updateBy != null and updateBy != ''">and UPDATE_BY = #{updateBy}</if>
<if test="updateTime != null ">and UPDATE_TIME = #{updateTime}</if>
</where>
ORDER BY CREATE_TIME DESC
</select>
<select id="selectWmsInventoryByWmsInventoryId" parameterType="Long" resultMap="WmsInventoryResult">
@ -134,8 +135,8 @@
<if test="systemCount != null">SYSTEM_COUNT = #{systemCount},</if>
<if test="inventoryCount != null">INVENTORY_COUNT = #{inventoryCount},</if>
<if test="inventoryTime != null">INVENTORY_TIME = #{inventoryTime},</if>
<if test="agCount != null">AG_COUNT = #{agCount},</if>
<if test="agTime != null">AG_TIME = #{agTime},</if>
AG_COUNT = #{agCount},
AG_TIME = #{agTime},
<if test="diffCount != null">DIFF_COUNT = #{diffCount},</if>
<if test="attr1 != null">ATTR1 = #{attr1},</if>
<if test="attr2 != null">ATTR2 = #{attr2},</if>

View File

@ -26,6 +26,34 @@
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<resultMap id="WmsInventoryPlanWmsInventoryResult" type="WmsInventoryPlan" extends="WmsInventoryPlanResult">
<collection property="wmsInventoryList" notNullColumn="sub_WMS_INVENTORY_ID" javaType="java.util.List"
resultMap="WmsInventoryResult"/>
</resultMap>
<resultMap type="WmsInventory" id="WmsInventoryResult">
<result property="wmsInventoryId" column="sub_WMS_INVENTORY_ID"/>
<result property="wmsStockPlanId" column="sub_WMS_STOCK_PLAN_ID"/>
<result property="mWarehouseId" column="sub_M_WAREHOUSE_ID"/>
<result property="areaId" column="sub_AREA_ID"/>
<result property="mdItemId" column="sub_MD_ITEM_ID"/>
<result property="unitId" column="sub_UNIT_ID"/>
<result property="systemCount" column="sub_SYSTEM_COUNT"/>
<result property="inventoryCount" column="sub_INVENTORY_COUNT"/>
<result property="inventoryTime" column="sub_INVENTORY_TIME"/>
<result property="agCount" column="sub_AG_COUNT"/>
<result property="agTime" column="sub_AG_TIME"/>
<result property="diffCount" column="sub_DIFF_COUNT"/>
<result property="attr1" column="sub_ATTR1"/>
<result property="attr2" column="sub_ATTR2"/>
<result property="attr3" column="sub_ATTR3"/>
<result property="attr4" column="sub_ATTR4"/>
<result property="createBy" column="sub_CREATE_BY"/>
<result property="createTime" column="sub_CREATE_TIME"/>
<result property="updateBy" column="sub_UPDATE_BY"/>
<result property="updateTime" column="sub_UPDATE_TIME"/>
</resultMap>
<sql id="selectWmsInventoryPlanVo">
select WMS_STOCK_PLAN_ID,
WMS_INVENTORY_CONFIGURE_ID,
@ -67,11 +95,53 @@
<if test="updateBy != null and updateBy != ''">and UPDATE_BY = #{updateBy}</if>
<if test="updateTime != null ">and UPDATE_TIME = #{updateTime}</if>
</where>
ORDER BY CREATE_TIME DESC
</select>
<select id="selectWmsInventoryPlanByWmsStockPlanId" parameterType="Long" resultMap="WmsInventoryPlanResult">
<include refid="selectWmsInventoryPlanVo"/>
where WMS_STOCK_PLAN_ID = #{wmsStockPlanId}
<select id="selectWmsInventoryPlanByWmsStockPlanId" parameterType="Long"
resultMap="WmsInventoryPlanWmsInventoryResult">
select a.WMS_STOCK_PLAN_ID,
a.WMS_INVENTORY_CONFIGURE_ID,
a.PLAN_CODE,
a.PLAN_NAME,
a.DATA_TYPE,
a.M_WAREHOUSE_ID,
a.BEGIN_TIME,
a.END_TIME,
a.ISAG,
a.STATUS,
a.DESCRIPTION,
a.ATTR1,
a.ATTR2,
a.ATTR3,
a.ATTR4,
a.CREATE_BY,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME,
b.WMS_INVENTORY_ID as sub_WMS_INVENTORY_ID,
b.WMS_STOCK_PLAN_ID as sub_WMS_STOCK_PLAN_ID,
b.M_WAREHOUSE_ID as sub_M_WAREHOUSE_ID,
b.AREA_ID as sub_AREA_ID,
b.MD_ITEM_ID as sub_MD_ITEM_ID,
b.UNIT_ID as sub_UNIT_ID,
b.SYSTEM_COUNT as sub_SYSTEM_COUNT,
b.INVENTORY_COUNT as sub_INVENTORY_COUNT,
b.INVENTORY_TIME as sub_INVENTORY_TIME,
b.AG_COUNT as sub_AG_COUNT,
b.AG_TIME as sub_AG_TIME,
b.DIFF_COUNT as sub_DIFF_COUNT,
b.ATTR1 as sub_ATTR1,
b.ATTR2 as sub_ATTR2,
b.ATTR3 as sub_ATTR3,
b.ATTR4 as sub_ATTR4,
b.CREATE_BY as sub_CREATE_BY,
b.CREATE_TIME as sub_CREATE_TIME,
b.UPDATE_BY as sub_UPDATE_BY,
b.UPDATE_TIME as sub_UPDATE_TIME
from WMS_INVENTORY_PLAN a
left join WMS_INVENTORY b on b.WMS_STOCK_PLAN_ID = a.WMS_STOCK_PLAN_ID
where a.WMS_STOCK_PLAN_ID = #{wmsStockPlanId}
</select>
<insert id="insertWmsInventoryPlan" parameterType="WmsInventoryPlan" useGeneratedKeys="true"
@ -156,4 +226,29 @@
#{wmsStockPlanId}
</foreach>
</delete>
<delete id="deleteWmsInventoryByWmsStockPlanIds" parameterType="String">
delete from WMS_INVENTORY where WMS_STOCK_PLAN_ID in
<foreach item="wmsStockPlanId" collection="array" open="(" separator="," close=")">
#{wmsStockPlanId}
</foreach>
</delete>
<delete id="deleteWmsInventoryByWmsStockPlanId" parameterType="Long">
delete
from WMS_INVENTORY
where WMS_STOCK_PLAN_ID = #{wmsStockPlanId}
</delete>
<insert id="batchWmsInventory">
insert into WMS_INVENTORY( WMS_INVENTORY_ID, WMS_STOCK_PLAN_ID, M_WAREHOUSE_ID, AREA_ID, MD_ITEM_ID, UNIT_ID,
SYSTEM_COUNT, INVENTORY_COUNT, INVENTORY_TIME, AG_COUNT, AG_TIME, DIFF_COUNT, ATTR1, ATTR2, ATTR3, ATTR4,
CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.wmsInventoryId}, #{item.wmsStockPlanId}, #{item.mWarehouseId}, #{item.areaId}, #{item.mdItemId},
#{item.unitId}, #{item.systemCount}, #{item.inventoryCount}, #{item.inventoryTime}, #{item.agCount},
#{item.agTime}, #{item.diffCount}, #{item.attr1}, #{item.attr2}, #{item.attr3}, #{item.attr4},
#{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
</mapper>