Merge remote-tracking branch 'origin/master'

This commit is contained in:
LJW 2024-11-13 17:18:53 +08:00
commit d7d689b74b
7 changed files with 162 additions and 21 deletions

View File

@ -1,26 +1,19 @@
package com.ktg.mes.md.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktg.common.annotation.Log;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.core.page.TableDataInfo;
import com.ktg.common.enums.BusinessType;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.mes.md.domain.WmsInventoryConfigure;
import com.ktg.mes.md.service.IWmsInventoryConfigureService;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 盘点计划配置Controller
@ -97,4 +90,11 @@ public class WmsInventoryConfigureController extends BaseController {
public AjaxResult remove(@PathVariable Long[] wmsInventoryConfigureIds) {
return toAjax(wmsInventoryConfigureService.deleteWmsInventoryConfigureByWmsInventoryConfigureIds(wmsInventoryConfigureIds));
}
@PreAuthorize("@ss.hasPermi('md:CONFIGURE:edit')")
@Log(title = "盘点计划配置", businessType = BusinessType.UPDATE)
@PutMapping("/auto-run/{wmsInventoryConfigureIds}")
public AjaxResult nowRun(@PathVariable Long[] wmsInventoryConfigureIds) {
return toAjax(wmsInventoryConfigureService.nowRunByWmsInventoryConfigureIds(wmsInventoryConfigureIds));
}
}

View File

@ -1,8 +1,9 @@
package com.ktg.mes.md.service;
import java.util.List;
import com.ktg.mes.md.domain.WmsInventoryConfigure;
import java.util.List;
/**
* 盘点计划配置Service接口
*
@ -53,9 +54,11 @@ public interface IWmsInventoryConfigureService
/**
* 删除盘点计划配置信息
*
*
* @param wmsInventoryConfigureId 盘点计划配置主键
* @return 结果
*/
public int deleteWmsInventoryConfigureByWmsInventoryConfigureId(Long wmsInventoryConfigureId);
public int nowRunByWmsInventoryConfigureIds(Long[] wmsInventoryConfigureIds);
}

View File

@ -1,14 +1,21 @@
package com.ktg.mes.md.service.impl;
import com.ktg.common.utils.DateUtils;
import com.ktg.mes.md.domain.WmsInventoryConfigure;
import com.ktg.mes.md.mapper.WmsInventoryConfigureMapper;
import com.ktg.mes.md.domain.*;
import com.ktg.mes.md.mapper.*;
import com.ktg.mes.md.service.IWmsInventoryConfigureService;
import com.ktg.mes.wm.domain.WmStorageArea;
import com.ktg.mes.wm.domain.WmStorageLocation;
import com.ktg.mes.wm.mapper.WmStorageAreaMapper;
import com.ktg.mes.wm.mapper.WmStorageLocationMapper;
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.List;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 盘点计划配置Service业务层处理
@ -24,6 +31,27 @@ public class WmsInventoryConfigureServiceImpl implements IWmsInventoryConfigureS
@Autowired
private WmWarehouseMapper wmWarehouseMapper;
@Autowired
private WmStorageLocationMapper wmStorageLocationMapper;
@Autowired
private WmStorageAreaMapper wmStorageAreaMapper;
@Autowired
private BaseKnifeMapper baseKnifeMapper;
@Autowired
private MdItemMapper mdItemMapper;
@Autowired
private MdUnitMeasureMapper mdUnitMeasureMapper;
@Autowired
private WmsInventoryPlanMapper wmsInventoryPlanMapper;
@Autowired
private WmsInventoryMapper wmsInventoryMapper;
/**
* 查询盘点计划配置
*
@ -97,4 +125,111 @@ public class WmsInventoryConfigureServiceImpl implements IWmsInventoryConfigureS
public int deleteWmsInventoryConfigureByWmsInventoryConfigureId(Long wmsInventoryConfigureId) {
return wmsInventoryConfigureMapper.deleteWmsInventoryConfigureByWmsInventoryConfigureId(wmsInventoryConfigureId);
}
@Transactional
@Override
public int nowRunByWmsInventoryConfigureIds(Long[] wmsInventoryConfigureIds) {
for (Long wmsInventoryConfigureId : wmsInventoryConfigureIds) {
// 获取当前时间字符串
Date nowDate = new Date(System.currentTimeMillis());
/* 集合存储物料实体集合 */
HashMap<Long, HashMap<String, List<BaseKnife>>> superBaseKnifeListHashMap = new HashMap<>();
/* 获得该盘点计划 */
WmsInventoryConfigure wmsInventoryConfigure = wmsInventoryConfigureMapper.selectWmsInventoryConfigureByWmsInventoryConfigureId(wmsInventoryConfigureId);
/* 开始时间与结束时间 */
String nowDateStr = new SimpleDateFormat("yyyy-MM-dd").format(nowDate);
Date startTime = nowDate;
Date endTime = nowDate;
try {
startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(nowDateStr + " 00:00:00");
endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(nowDateStr + " 23:59:59");
} catch (ParseException ignored) {
}
/* 构建盘点计划数据 */
WmsInventoryPlan wmsInventoryPlan = new WmsInventoryPlan();
wmsInventoryPlan.setWmsInventoryConfigureId(wmsInventoryConfigure.getWmsInventoryConfigureId());
wmsInventoryPlan.setPlanCode(String.format("%s_%s_%s", wmsInventoryConfigure.getDataType(), wmsInventoryConfigure.getInventoryType(), Long.toString(System.currentTimeMillis(), 32).toUpperCase(Locale.ROOT)));
wmsInventoryPlan.setPlanName(wmsInventoryConfigure.getConfigureName());
wmsInventoryPlan.setDataType(wmsInventoryConfigure.getDataType());
wmsInventoryPlan.setmWarehouseId(wmsInventoryConfigure.getmWarehouseId());
wmsInventoryPlan.setBeginTime(startTime);
wmsInventoryPlan.setEndTime(endTime);
wmsInventoryPlan.setStatus("STATUS_1");
wmsInventoryPlan.setDescription(String.format("%s自动生成的盘点计划。", new SimpleDateFormat("yyyy年MM月dd日").format(nowDate)));
wmsInventoryPlan.setIsag("N");
wmsInventoryPlan.setCreateTime(nowDate);
/* 保存盘点计划数据 */
wmsInventoryPlanMapper.insertWmsInventoryPlan(wmsInventoryPlan);
/* 以新创建的盘点计划ID为主键构建集合 */
superBaseKnifeListHashMap.computeIfAbsent(wmsInventoryPlan.getWmsStockPlanId(), k -> new HashMap<>());
/* 根据仓库ID获取库区列表 */
WmStorageLocation wmStorageLocationQuery = new WmStorageLocation();
wmStorageLocationQuery.setWarehouseId(wmsInventoryConfigure.getmWarehouseId());
List<WmStorageLocation> wmStorageLocationList = wmStorageLocationMapper.selectWmStorageLocationList(wmStorageLocationQuery);
wmStorageLocationList.forEach(wmStorageLocation -> {
/* 根据库区ID获取库位列表 */
WmStorageArea wmStorageAreaQuery = new WmStorageArea();
wmStorageAreaQuery.setLocationId(wmStorageLocation.getLocationId());
List<WmStorageArea> wmStorageAreaList = wmStorageAreaMapper.selectWmStorageAreaList(wmStorageAreaQuery);
wmStorageAreaList.forEach(wmStorageArea -> {
/* 根据库位编码获取台账列表 */
BaseKnife baseKnifeQuery = new BaseKnife();
baseKnifeQuery.setAreaCode(wmStorageArea.getAreaCode());
baseKnifeQuery.setKnifeFineState(1);
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeQuery);
baseKnifeList.forEach(baseKnife -> {
/* 获取无聊信息 */
MdItem mdItem = mdItemMapper.selectMdItemById(baseKnife.getMbbBdMrlId());
/* 获得单位信息 */
MdUnitMeasure mdUnitMeasure = mdUnitMeasureMapper.selectMdUnitByCode(mdItem.getUnitOfMeasure());
/* 根据无聊信息构建无聊信息数 */
String key = wmsInventoryConfigure.getmWarehouseId().toString() + "-" +
wmStorageArea.getAreaId().toString() + "-" +
baseKnife.getMbbBdMrlId().toString() + "-" +
mdUnitMeasure.getMeasureId().toString();
/* 校验是否存在该列表 */
superBaseKnifeListHashMap.get(wmsInventoryPlan.getWmsStockPlanId()).computeIfAbsent(key, k -> new ArrayList<>());
/* 填入数据 */
superBaseKnifeListHashMap.get(wmsInventoryPlan.getWmsStockPlanId()).get(key).add(baseKnife);
});
});
});
/* 遍历集合 */
superBaseKnifeListHashMap.keySet().forEach(key1 -> {
System.out.println(key1);
superBaseKnifeListHashMap.get(key1).keySet().forEach(key2 -> {
System.out.println("\t" + key2);
/* 切割字符串 */
String[] idStrArray = key2.split("-");
/* 构建数据 */
WmsInventory wmsInventory = new WmsInventory();
wmsInventory.setWmsStockPlanId(key1);
wmsInventory.setmWarehouseId(Long.valueOf(idStrArray[0]));
wmsInventory.setAreaId(Long.valueOf(idStrArray[1]));
wmsInventory.setMdItemId(Long.valueOf(idStrArray[2]));
wmsInventory.setUnitId(Long.valueOf(idStrArray[3]));
wmsInventory.setSystemCount(superBaseKnifeListHashMap.get(key1).get(key2).size());
wmsInventory.setCreateTime(nowDate);
/* 保存数据 */
wmsInventoryMapper.insertWmsInventory(wmsInventory);
});
});
}
return wmsInventoryConfigureIds.length;
}
}

View File

@ -63,7 +63,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 bom_version desc
ORDER BY MD_ITEM_ID ASC, IS_DEFAULT DESC, BOM_VERSION DESC, CREATE_TIME DESC
</select>
<select id="selectBomRouteByBomRouteId" parameterType="Long" resultMap="BomRouteMbbProduBomResult">

View File

@ -79,6 +79,7 @@
#{standardQuantity}
</if>
</where>
ORDER BY WMS_OUT_PLAN_DETAIL_ID DESC, CREATE_TIME DESC
</select>
<select id="selectWmsOutPlanDetailEntityByWmsOutPlanDetailEntityId" parameterType="Long"

View File

@ -129,6 +129,7 @@
and UPDATE_TIME = #{updateTime}
</if>
</where>
ORDER BY CREATE_TIME DESC
</select>
<select id="selectWmsOutPlanByWmsOutPlanId" parameterType="Long" resultMap="WmsOutPlanWmsOutPlanDetailResult">

View File

@ -60,6 +60,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 WMS_OUT_PLAN_ID DESC, WMS_OUT_PLAN_DETAIL_ID DESC, CREATE_TIME DESC
</select>
<select id="selectWmsOutTaskByWmsOutTaskId" parameterType="Long" resultMap="WmsOutTaskResult">