Merge remote-tracking branch 'origin/master'

This commit is contained in:
liumingxiy 2024-11-15 09:15:13 +08:00
commit ffa6dc4e99
16 changed files with 634 additions and 129 deletions

View File

@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.ktg.common.utils.DateUtils;
import com.ktg.generator.util.MultiModuleCodeGenerator;
import com.ktg.mes.md.domain.*;
import com.ktg.mes.md.mapper.WmsOutPlanDetailEntityMapper;
import com.ktg.mes.md.mapper.WmsOutPlanMapper;
@ -33,14 +34,13 @@ import static com.ktg.generator.util.MultiModuleCodeGenerator.generateTaskCode;
/**
* 工具台账Controller
*
*
* @author yinjinlu
* @date 2024-10-31
*/
@RestController
@RequestMapping("/mes/md/baseKnife")
public class BaseKnifeController extends BaseController
{
public class BaseKnifeController extends BaseController {
@Autowired
private IBaseKnifeService baseKnifeService;
@ -101,9 +101,9 @@ public class BaseKnifeController extends BaseController
map.put("knifeLifeLeave", item.getKnifeLife() == 0 ? null : String.valueOf(item.getKnifeLife()));
map.put("isLocked", item.getIsLocked());
map.put("lockedStartTime", item.getLockedStartTime() == null ? null : item.getLockedStartTime());
map.put("lockedEndTime",item.getLockedEndTime() == null ? null : item.getLockedEndTime());
map.put("planSheet",item.getPlanSheet() == null ? null : item.getPlanSheet());
map.put("outInfoList", item.getOutInfoList() );
map.put("lockedEndTime", item.getLockedEndTime() == null ? null : item.getLockedEndTime());
map.put("planSheet", item.getPlanSheet() == null ? null : item.getPlanSheet());
map.put("outInfoList", item.getOutInfoList());
result.add(map);
});
@ -155,13 +155,13 @@ public class BaseKnifeController extends BaseController
MdItem mdItemTemp = new MdItem();
// 遍历工艺bom 所需要的所有材料
for (BaseTechnologyBom techBom : technologyBomList){
for (BaseTechnologyBom techBom : technologyBomList) {
// 空则0
countMap.putIfAbsent(techBom.getKnifeCode(), 0);
// 台账表中查询工具 并记录数量
mdItemTemp = mdItemService.selectMdItemByCode(techBom.getKnifeCode());
if (mdItemTemp == null){
if (mdItemTemp == null) {
operLog.setJsonResult("物料台账查询错误:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("物料台账查询错误", techBom.getKnifeCode());
@ -170,16 +170,16 @@ public class BaseKnifeController extends BaseController
baseKnifeWrapper.setMbbBdMrlId(mdItemTemp.getItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> tempList = this.baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
tempList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
tempList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
AtomicInteger knifeCount = new AtomicInteger(techBom.getKnifeCount());
// 如果台账表中不存在尝试组刀任务查询
if (tempList.isEmpty()){
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())){
if (tempList.isEmpty()) {
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
// 查询整刀bom项 如果不存在说明 为基础物料或者没有记录此整刀的组装
bomRouteTemp.setMdItemId(mdItemTemp.getItemId());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()){
if (bomRouteList.isEmpty()) {
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode());
@ -189,18 +189,18 @@ public class BaseKnifeController extends BaseController
if (!bomRoute.getMbbProduBomList().isEmpty()) {
// 遍历bom项 从台账表中筛选对应基础物料
for (MbbProduBom bom : bomRoute.getMbbProduBomList()){
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
// 查询基础物料不包含已锁定的
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
if (sitmTempList.isEmpty()){
if (sitmTempList.isEmpty()) {
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null){
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()){
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null) {
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()) {
countMap.put(sitmTempList.get(0).getKnifeCode(), bom.getStandardDosage() * knifeCount.get());
} else {
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
@ -212,7 +212,7 @@ public class BaseKnifeController extends BaseController
}
// 判断基础物料是否充足
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()){
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()) {
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
@ -237,13 +237,13 @@ public class BaseKnifeController extends BaseController
countMap.put(item.getKnifeCode(), countMap.get(item.getKnifeCode()) + 1);
}
});
if (knifeCount.get() > 0) {
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())){
if (knifeCount.get() > 0) {
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
// 查询整刀bom项 如果不存在说明 为基础物料或者没有记录此整刀的组装
bomRouteTemp.setMdItemId(mdItemTemp.getItemId());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()){
if (bomRouteList.isEmpty()) {
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode());
@ -253,18 +253,18 @@ public class BaseKnifeController extends BaseController
if (!bomRoute.getMbbProduBomList().isEmpty()) {
// 遍历bom项 从台账表中筛选对应基础物料
for (MbbProduBom bom : bomRoute.getMbbProduBomList()){
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
// 查询基础物料不包含已锁定的
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
if (sitmTempList.isEmpty()){
if (sitmTempList.isEmpty()) {
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null){
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()){
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null) {
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()) {
countMap.put(sitmTempList.get(0).getKnifeCode(), bom.getStandardDosage() * knifeCount.get());
} else {
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
@ -276,7 +276,7 @@ public class BaseKnifeController extends BaseController
}
// 判断基础物料是否充足
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()){
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()) {
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
@ -306,12 +306,19 @@ public class BaseKnifeController extends BaseController
@PostMapping("/open/productionArrangements/{planSheet}")
@ResponseBody
public AjaxResult productionArrangements(@PathVariable String planSheet, @RequestBody List<String> processCodeList) {
// 检查计划单是否已存在
BaseKnife baseKnifePlan = new BaseKnife();
baseKnifePlan.setPlanSheet(planSheet);
if (!baseKnifeService.selectBaseKnifeList(baseKnifePlan).isEmpty())
return AjaxResult.error("该计划单已存在,请更换重试");
// 齐套性检查
AjaxResult ajaxResult = this.checkForAlignment(processCodeList);
if (Integer.parseInt(String.valueOf(ajaxResult.get("code"))) != 200){
return AjaxResult.error(ajaxResult.get("msg").toString(), ajaxResult.get("data"));
}
// 验证bom工艺
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomListByProcessCodeList(processCodeList);
if (technologyBomList.isEmpty() || technologyBomList.size() == 1 && technologyBomList.get(0).getKnifeCode() == null)
@ -348,13 +355,13 @@ public class BaseKnifeController extends BaseController
MdItem mdItemTemp = new MdItem();
// 遍历工艺bom 所需要的所有材料
for (BaseTechnologyBom techBom : technologyBomList){
for (BaseTechnologyBom techBom : technologyBomList) {
// 空则0
countMap.putIfAbsent(techBom.getKnifeCode(), 0);
// 台账表中查询工具 并记录数量
mdItemTemp = mdItemService.selectMdItemByCode(techBom.getKnifeCode());
if (mdItemTemp == null){
if (mdItemTemp == null) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("物料台账查询错误:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
@ -365,16 +372,16 @@ public class BaseKnifeController extends BaseController
baseKnifeWrapper.setMbbBdMrlId(mdItemTemp.getItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> tempList = this.baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
tempList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
tempList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
AtomicInteger knifeCount = new AtomicInteger(techBom.getKnifeCount());
// 如果台账表中不存在尝试组刀任务查询
if (tempList.isEmpty()){
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())){
if (tempList.isEmpty()) {
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
// 查询整刀bom项 如果不存在说明 为基础物料或者没有记录此整刀的组装
bomRouteTemp.setMdItemId(mdItemTemp.getItemId());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()){
if (bomRouteList.isEmpty()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
@ -385,19 +392,19 @@ public class BaseKnifeController extends BaseController
if (!bomRoute.getMbbProduBomList().isEmpty()) {
// 遍历bom项 从台账表中筛选对应基础物料
for (MbbProduBom bom : bomRoute.getMbbProduBomList()){
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
// 查询基础物料不包含已锁定的
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
if (sitmTempList.isEmpty()){
if (sitmTempList.isEmpty()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null){
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()){
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null) {
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()) {
countMap.put(sitmTempList.get(0).getKnifeCode(), bom.getStandardDosage() * knifeCount.get());
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
@ -410,7 +417,7 @@ public class BaseKnifeController extends BaseController
}
// 判断基础物料是否充足
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()){
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
@ -445,13 +452,13 @@ public class BaseKnifeController extends BaseController
baseKnifeService.updateBaseKnife(item);
}
});
if (knifeCount.get() > 0) {
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())){
if (knifeCount.get() > 0) {
if ("PRODUCT".equals(mdItemTemp.getItemOrProduct())) {
// 查询整刀bom项 如果不存在说明 为基础物料或者没有记录此整刀的组装
bomRouteTemp.setMdItemId(mdItemTemp.getItemId());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()){
if (bomRouteList.isEmpty()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
@ -462,19 +469,19 @@ public class BaseKnifeController extends BaseController
if (!bomRoute.getMbbProduBomList().isEmpty()) {
// 遍历bom项 从台账表中筛选对应基础物料
for (MbbProduBom bom : bomRoute.getMbbProduBomList()){
for (MbbProduBom bom : bomRoute.getMbbProduBomList()) {
// 查询基础物料不包含已锁定的
baseKnifeWrapper.setMbbBdMrlId(bom.getMdItemId());
baseKnifeWrapper.setIsLocked(0);
List<BaseKnife> sitmTempList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
if (sitmTempList.isEmpty()){
if (sitmTempList.isEmpty()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + bom.getMdItemCode());
operLogService.insertOperlog(operLog);
return AjaxResult.error("基础物料不足进行组装工具", bom.getMdItemCode());
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null){
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()){
} else if (countMap.get(sitmTempList.get(0).getKnifeCode()) == null) {
if (sitmTempList.size() >= bom.getStandardDosage() * knifeCount.get()) {
countMap.put(sitmTempList.get(0).getKnifeCode(), bom.getStandardDosage() * knifeCount.get());
} else {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
@ -487,7 +494,7 @@ public class BaseKnifeController extends BaseController
}
// 判断基础物料是否充足
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()){
if (sitmTempList.size() < countMap.get(sitmTempList.get(0).getKnifeCode()) && countMap.get(sitmTempList.get(0).getKnifeCode()) > bom.getStandardDosage() * knifeCount.get()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("基础物料不足进行组装工具:" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
@ -515,7 +522,7 @@ public class BaseKnifeController extends BaseController
List<BaseKnife> baseKnifeList;
int count;
List<MbbProduBom> bomList;
for (BaseTechnologyBom techBom : technologyBomList){
for (BaseTechnologyBom techBom : technologyBomList) {
mdItem = mdItemService.selectMdItemByCode(techBom.getKnifeCode());
count = techBom.getKnifeCount() - countMap.get(techBom.getKnifeCode());
@ -523,21 +530,21 @@ public class BaseKnifeController extends BaseController
baseKnifeWrapper.setMbbBdMrlId(mdItem.getItemId());
baseKnifeWrapper.setIsLocked(0);
baseKnifeList = baseKnifeService.selectBaseKnifeList(baseKnifeWrapper);
baseKnifeList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
for (BaseKnife wmsBaseKnife : baseKnifeList){
if (wmsBaseKnife.getKnifeLife() >= techBom.getExpendLife() && count > 0){
baseKnifeList.removeIf(baseKnife -> baseKnife.getKnifeLife() + baseKnife.getResetCount() * 100 < techBom.getExpendLife());
for (BaseKnife wmsBaseKnife : baseKnifeList) {
if (wmsBaseKnife.getKnifeLife() >= techBom.getExpendLife() && count > 0) {
count--;
}
}
// 整刀不足进行组装
if (count > 0){
if ("PRODUCT".equals(mdItem.getItemOrProduct())){
if (count > 0) {
if ("PRODUCT".equals(mdItem.getItemOrProduct())) {
// 查询整刀bom项 如果不存在说明 为基础物料或者没有记录此整刀的组装
bomRouteTemp.setMdItemId(mdItem.getItemId());
List<BomRoute> bomRouteList = bomRouteService.selectBomRouteList(bomRouteTemp);
if (bomRouteList.isEmpty()){
if (bomRouteList.isEmpty()) {
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
operLog.setJsonResult("Bom头查询错误" + techBom.getKnifeCode());
operLogService.insertOperlog(operLog);
@ -577,8 +584,7 @@ public class BaseKnifeController extends BaseController
@PreAuthorize("@ss.hasPermi('md:baseKnife:edit')")
@Log(title = "工具台账", businessType = BusinessType.UPDATE)
@PutMapping("/zdTask")
public AjaxResult zdTask(@RequestBody WmsZdTask zdTask)
{
public AjaxResult zdTask(@RequestBody WmsZdTask zdTask) {
String batchNum = "ZZPC001";
// 判断物料是否充足
@ -605,13 +611,13 @@ public class BaseKnifeController extends BaseController
BaseTechnologyBom technologyBom = new BaseTechnologyBom();
Boolean lockedFlag = false;
// attr4 组装任务所属计划单 如果为空则是手动组装任务不需要锁定
if (zdTask.getAttr4() != null){
if (zdTask.getAttr4() != null) {
lockedFlag = true;
}
// 出库基础物料 根据图号查询出库计划如果不存在生成计划存在则往计划中添加任务
WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(zdTask.getAttr4());
if (outPlan == null){
if (outPlan == null) {
// 构建新的出库计划
WmsOutPlan outPlanTemp = new WmsOutPlan();
outPlanTemp.setPlanCode(zdTask.getAttr4() == null ? zdTask.getCode() : zdTask.getAttr4());
@ -687,8 +693,8 @@ public class BaseKnifeController extends BaseController
// 锁定基础 物料
int bomCount = mbbProduBom.getStandardDosage();
for (BaseKnife wmsBaseKnife : baseKnifeList){
if (bomCount > 0){
for (BaseKnife wmsBaseKnife : baseKnifeList) {
if (bomCount > 0) {
wmsBaseKnife.setIsLocked(1);
wmsBaseKnife.setKnifeFineState(2);
wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
@ -712,7 +718,7 @@ public class BaseKnifeController extends BaseController
// 出库
int i = 0;
for (WmsOutPlanDetail outPlanDetail : wmsOutPlanDetailList){
for (WmsOutPlanDetail outPlanDetail : wmsOutPlanDetailList) {
wmsOutPlanMapper.insertWmsOutPlanDetail(outPlanDetail);
// 出库计划明细绑定实体
@ -764,7 +770,7 @@ public class BaseKnifeController extends BaseController
// 整刀入库计划, 根据图号查询入库计划如果不存在生成计划存在则往计划中添加任务
WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getAttr4());
if (wmsInPlan == null){
if (wmsInPlan == null) {
WmsInPlan wmsInPlanTemp = new WmsInPlan();
wmsInPlanTemp.setState("1");
wmsInPlanTemp.setSourceType("SGLR");
@ -780,7 +786,7 @@ public class BaseKnifeController extends BaseController
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails();
wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString());
wmsInPlanDetails.setBatch(batchNum);
wmsInPlanDetails.setCellId("1");
wmsInPlanDetails.setCellId(1L);
wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString());
wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString());
wmsInPlanDetails.setPlanInStatus("0");
@ -794,7 +800,7 @@ public class BaseKnifeController extends BaseController
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails();
wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString());
wmsInPlanDetails.setBatch(batchNum);
wmsInPlanDetails.setCellId("1");
wmsInPlanDetails.setCellId(1L);
wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString());
wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString());
wmsInPlanDetails.setPlanInStatus("0");
@ -806,6 +812,9 @@ public class BaseKnifeController extends BaseController
// 入库任务
MdItem mdItem = mdItemService.selectMdItemById(zdTask.getmProductId());
WmsInTask wmsInTask = new WmsInTask();
// 生成任务号
String taskInCode = MultiModuleCodeGenerator.generateTaskCode("RKT");
wmsInTask.setTaskInCode(taskInCode);
wmsInTask.setPlanInId(wmsInPlan.getPlanId().toString());
wmsInTask.setPlanInCode(wmsInPlan.getPlanCode());
wmsInTask.setMaterialCode(mdItem.getItemCode());
@ -834,13 +843,12 @@ public class BaseKnifeController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('md:baseKnife:list')")
@GetMapping("/list")
public TableDataInfo list(BaseKnife baseKnife)
{
public TableDataInfo list(BaseKnife baseKnife) {
startPage();
List<BaseKnife> list = baseKnifeService.selectBaseKnifeList(baseKnife);
list.forEach(item -> {
// 查询基础物料
if ("PRODUCT".equals(item.getItemOrProduct())){
if ("PRODUCT".equals(item.getItemOrProduct())) {
BaseKnife baseKnifeWrapper = new BaseKnife();
baseKnifeWrapper.setAttr1(item.getBaseKnifeId());
item.setBaseKnifeList(baseKnifeService.selectBaseKnifeList(baseKnifeWrapper));
@ -855,8 +863,7 @@ public class BaseKnifeController extends BaseController
@PreAuthorize("@ss.hasPermi('md:baseKnife:export')")
@Log(title = "工具台账", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BaseKnife baseKnife)
{
public void export(HttpServletResponse response, BaseKnife baseKnife) {
List<BaseKnife> list = baseKnifeService.selectBaseKnifeList(baseKnife);
ExcelUtil<BaseKnife> util = new ExcelUtil<BaseKnife>(BaseKnife.class);
util.exportExcel(response, list, "工具台账数据");
@ -867,8 +874,7 @@ public class BaseKnifeController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('md:baseKnife:query')")
@GetMapping(value = "/{baseKnifeId}")
public AjaxResult getInfo(@PathVariable("baseKnifeId") Long baseKnifeId)
{
public AjaxResult getInfo(@PathVariable("baseKnifeId") Long baseKnifeId) {
return AjaxResult.success(baseKnifeService.selectBaseKnifeByBaseKnifeId(baseKnifeId));
}
@ -878,8 +884,7 @@ public class BaseKnifeController extends BaseController
@PreAuthorize("@ss.hasPermi('md:baseKnife:add')")
@Log(title = "工具台账", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BaseKnife baseKnife)
{
public AjaxResult add(@RequestBody BaseKnife baseKnife) {
return toAjax(baseKnifeService.insertBaseKnife(baseKnife));
}
@ -889,8 +894,7 @@ public class BaseKnifeController extends BaseController
@PreAuthorize("@ss.hasPermi('md:baseKnife:edit')")
@Log(title = "工具台账", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BaseKnife baseKnife)
{
public AjaxResult edit(@RequestBody BaseKnife baseKnife) {
return toAjax(baseKnifeService.updateBaseKnife(baseKnife));
}
@ -900,8 +904,7 @@ public class BaseKnifeController extends BaseController
@PreAuthorize("@ss.hasPermi('md:baseKnife:edit')")
@Log(title = "工具台账", businessType = BusinessType.UPDATE)
@PutMapping("/reset/{baseKnifeId}")
public AjaxResult reset(@PathVariable Long baseKnifeId)
{
public AjaxResult reset(@PathVariable Long baseKnifeId) {
return toAjax(baseKnifeService.resetBaseKnifeByBaseKnifeId(baseKnifeId));
}
@ -910,9 +913,8 @@ public class BaseKnifeController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('md:baseKnife:remove')")
@Log(title = "工具台账", businessType = BusinessType.DELETE)
@DeleteMapping("/{baseKnifeIds}")
public AjaxResult remove(@PathVariable Long[] baseKnifeIds)
{
@DeleteMapping("/{baseKnifeIds}")
public AjaxResult remove(@PathVariable Long[] baseKnifeIds) {
return toAjax(baseKnifeService.deleteBaseKnifeByBaseKnifeIds(baseKnifeIds));
}
}

View File

@ -4,6 +4,9 @@ import com.ktg.common.utils.DateUtils;
import com.ktg.mes.md.domain.*;
import com.ktg.mes.md.mapper.*;
import com.ktg.mes.md.service.IBaseKnifeService;
import com.ktg.mes.wm.domain.WmsInPlanDetailEntity;
import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper;
import com.ktg.mes.wm.service.impl.WmsInPlanDetailEntityServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -38,6 +41,12 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService {
@Autowired
private WmsBusinessTypeMapper wmsBusinessTypeMapper;
@Autowired
private WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper;
@Autowired
private WmsInPlanDetailEntityServiceImpl wmsInPlanDetailEntityService;
/**
* 查询工具台账
*
@ -104,6 +113,12 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService {
// 注入出库信息对象
nowBaseKnife.setOutInfoList(hashMapList);
});
// 构建入库信息
WmsInPlanDetailEntity wmsInPlanDetailEntityQuery = new WmsInPlanDetailEntity();
wmsInPlanDetailEntityQuery.setKnifeId(nowBaseKnife.getBaseKnifeId());
List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetailEntityService.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntityQuery);
nowBaseKnife.setInInfoList(wmsInPlanDetailEntityList);
});
return baseKnifeList;

View File

@ -2,6 +2,7 @@ package com.ktg.mes.wm.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;
@ -23,14 +24,13 @@ import com.ktg.common.core.page.TableDataInfo;
/**
* 入库计划Controller
*
*
* @author yinjinlu
* @date 2024-10-31
*/
@RestController
@RequestMapping("/wm/PLAN")
public class WmsInPlanController extends BaseController
{
public class WmsInPlanController extends BaseController {
@Autowired
private IWmsInPlanService wmsInPlanService;
@ -39,8 +39,7 @@ public class WmsInPlanController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('wm:PLAN:list')")
@GetMapping("/list")
public TableDataInfo list(WmsInPlan wmsInPlan)
{
public TableDataInfo list(WmsInPlan wmsInPlan) {
startPage();
List<WmsInPlan> list = wmsInPlanService.selectWmsInPlanList(wmsInPlan);
return getDataTable(list);
@ -52,8 +51,7 @@ public class WmsInPlanController extends BaseController
@PreAuthorize("@ss.hasPermi('wm:PLAN:export')")
@Log(title = "入库计划", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, WmsInPlan wmsInPlan)
{
public void export(HttpServletResponse response, WmsInPlan wmsInPlan) {
List<WmsInPlan> list = wmsInPlanService.selectWmsInPlanList(wmsInPlan);
ExcelUtil<WmsInPlan> util = new ExcelUtil<WmsInPlan>(WmsInPlan.class);
util.exportExcel(response, list, "入库计划数据");
@ -64,19 +62,23 @@ public class WmsInPlanController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('wm:PLAN:query')")
@GetMapping(value = "/{planId}")
public AjaxResult getInfo(@PathVariable("planId") String planId)
{
public AjaxResult getInfo(@PathVariable("planId") String planId) {
return AjaxResult.success(wmsInPlanService.selectWmsInPlanByPlanId(planId));
}
@PreAuthorize("@ss.hasPermi('wm:PLAN:query')")
@GetMapping(value = "/isDuplicatePlanCode/{planCode}")
public AjaxResult isDuplicatePlanCode(@PathVariable("planCode") String planCode) {
return AjaxResult.success(wmsInPlanService.isDuplicatePlanCode(planCode));
}
/**
* 新增入库计划
*/
@PreAuthorize("@ss.hasPermi('wm:PLAN:add')")
@Log(title = "入库计划", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WmsInPlan wmsInPlan)
{
public AjaxResult add(@RequestBody WmsInPlan wmsInPlan) {
return toAjax(wmsInPlanService.insertWmsInPlan(wmsInPlan));
}
@ -86,8 +88,7 @@ public class WmsInPlanController extends BaseController
@PreAuthorize("@ss.hasPermi('wm:PLAN:edit')")
@Log(title = "入库计划", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WmsInPlan wmsInPlan)
{
public AjaxResult edit(@RequestBody WmsInPlan wmsInPlan) {
return toAjax(wmsInPlanService.updateWmsInPlan(wmsInPlan));
}
@ -96,9 +97,8 @@ public class WmsInPlanController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('wm:PLAN:remove')")
@Log(title = "入库计划", businessType = BusinessType.DELETE)
@DeleteMapping("/{planIds}")
public AjaxResult remove(@PathVariable String[] planIds)
{
@DeleteMapping("/{planIds}")
public AjaxResult remove(@PathVariable String[] planIds) {
return toAjax(wmsInPlanService.deleteWmsInPlanByPlanIds(planIds));
}
}

View File

@ -34,6 +34,29 @@ public class WmsZdTaskController extends BaseController
@Autowired
private IWmsZdTaskService wmsZdTaskService;
/**
* 开始组装任务
*/
@PreAuthorize("@ss.hasPermi('wm:zdTask:edit')")
@Log(title = "开始组装", businessType = BusinessType.UPDATE)
@PutMapping("/out")
public AjaxResult out(@RequestBody WmsZdTask wmsZdTask)
{
return wmsZdTaskService.createOutTaskByWmsZdTask(wmsZdTask);
}
/**
* 完成组装任务
*/
@PreAuthorize("@ss.hasPermi('wm:zdTask:edit')")
@Log(title = "完成组装", businessType = BusinessType.UPDATE)
@PutMapping("/in")
public AjaxResult in(@RequestBody WmsZdTask wmsZdTask)
{
return wmsZdTaskService.createInTaskByWmsZdTask(wmsZdTask);
}
/**
* 查询组装任务列表
*/

View File

@ -55,6 +55,36 @@ public class WmsInPlanDetailEntity extends BaseEntity {
@Excel(name = "消耗寿命")
private Integer consumeLife;
/**
* 入库计划编码
*/
private String planCode;
/**
* 计划状态
*/
private String planState;
/**
* 来源类型手工录入等
*/
private String planSourceType;
/**
* 入库计划类型
*/
private String planType;
/**
* 库位编码
*/
private String cellCode;
/**
* 库位名称
*/
private String cellName;
/**
* 明细批次
*/
private String detailBatch;
public void setId(Long id) {
this.id = id;
}
@ -111,11 +141,74 @@ public class WmsInPlanDetailEntity extends BaseEntity {
return consumeLife;
}
public String getPlanCode() {
return planCode;
}
public void setPlanCode(String planCode) {
this.planCode = planCode;
}
public String getPlanState() {
return planState;
}
public void setPlanState(String planState) {
this.planState = planState;
}
public String getPlanSourceType() {
return planSourceType;
}
public void setPlanSourceType(String planSourceType) {
this.planSourceType = planSourceType;
}
public String getPlanType() {
return planType;
}
public void setPlanType(String planType) {
this.planType = planType;
}
public String getCellCode() {
return cellCode;
}
public void setCellCode(String cellCode) {
this.cellCode = cellCode;
}
public String getCellName() {
return cellName;
}
public void setCellName(String cellName) {
this.cellName = cellName;
}
public String getDetailBatch() {
return detailBatch;
}
public void setDetailBatch(String detailBatch) {
this.detailBatch = detailBatch;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("planId", getPlanId())
.append("planCode", getPlanCode())
.append("planState", getPlanState())
.append("planSourceType", getPlanSourceType())
.append("planType", getPlanType())
.append("cellCode", getCellCode())
.append("cellName", getCellName())
.append("detailBatch", getDetailBatch())
.append("planDetailsId", getPlanDetailsId())
.append("source", getSource())
.append("knifeId", getKnifeId())

View File

@ -36,7 +36,7 @@ public class WmsInPlanDetails extends BaseEntity
/** 库位 */
@Excel(name = "库位")
private String cellId;
private Long cellId;
/** 计划数量 */
@Excel(name = "计划数量")
@ -94,12 +94,12 @@ public class WmsInPlanDetails extends BaseEntity
{
return batch;
}
public void setCellId(String cellId)
public void setCellId(Long cellId)
{
this.cellId = cellId;
}
public String getCellId()
public Long getCellId()
{
return cellId;
}

View File

@ -86,4 +86,11 @@ public interface WmsInPlanMapper
public int deleteWmsInPlanDetailsByPlanId(String planId);
WmsInPlan selectWmsInPlanByPlanCode(String planCode);
/**
* 判断计划ID是否有重复
* @param planCode 计划ID
* @return 结果
*/
public Boolean isDuplicatePlanCode(String planCode);
}

View File

@ -61,4 +61,10 @@ public interface IWmsInPlanService
*/
public int deleteWmsInPlanByPlanId(String planId);
/**
* 入库计划ID是否重复
* @param planCode 入库计划ID
* @return 是否重复
*/
public Boolean isDuplicatePlanCode(String planCode);
}

View File

@ -1,6 +1,8 @@
package com.ktg.mes.wm.service;
import java.util.List;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.mes.wm.domain.WmsZdTask;
/**
@ -58,4 +60,8 @@ public interface IWmsZdTaskService
* @return 结果
*/
public int deleteWmsZdTaskByWmsZdTaskId(String wmsZdTaskId);
AjaxResult createOutTaskByWmsZdTask(WmsZdTask wmsZdTask);
AjaxResult createInTaskByWmsZdTask(WmsZdTask wmsZdTask);
}

View File

@ -1,7 +1,15 @@
package com.ktg.mes.wm.service.impl;
import java.util.List;
import java.util.*;
import com.ktg.common.utils.DateUtils;
import com.ktg.mes.md.domain.WmsBusinessType;
import com.ktg.mes.md.mapper.WmsBusinessTypeMapper;
import com.ktg.mes.wm.domain.WmStorageArea;
import com.ktg.mes.wm.domain.WmsInPlan;
import com.ktg.mes.wm.domain.WmsInPlanDetails;
import com.ktg.mes.wm.mapper.WmStorageAreaMapper;
import com.ktg.mes.wm.mapper.WmsInPlanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper;
@ -10,25 +18,32 @@ import com.ktg.mes.wm.service.IWmsInPlanDetailEntityService;
/**
* 入库计划明细实体Service业务层处理
*
*
* @author yinjinlu
* @date 2024-11-05
*/
@Service
public class WmsInPlanDetailEntityServiceImpl implements IWmsInPlanDetailEntityService
{
public class WmsInPlanDetailEntityServiceImpl implements IWmsInPlanDetailEntityService {
@Autowired
private WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper;
@Autowired
private WmsInPlanMapper wmsInPlanMapper;
@Autowired
private WmsBusinessTypeMapper wmsBusinessTypeMapper;
@Autowired
private WmStorageAreaMapper wmStorageAreaMapper;
/**
* 查询入库计划明细实体
*
*
* @param id 入库计划明细实体主键
* @return 入库计划明细实体
*/
@Override
public WmsInPlanDetailEntity selectWmsInPlanDetailEntityById(Long id)
{
public WmsInPlanDetailEntity selectWmsInPlanDetailEntityById(Long id) {
return wmsInPlanDetailEntityMapper.selectWmsInPlanDetailEntityById(id);
}
@ -45,63 +60,85 @@ public class WmsInPlanDetailEntityServiceImpl implements IWmsInPlanDetailEntityS
/**
* 查询入库计划明细实体列表
*
*
* @param wmsInPlanDetailEntity 入库计划明细实体
* @return 入库计划明细实体
*/
@Override
public List<WmsInPlanDetailEntity> selectWmsInPlanDetailEntityList(WmsInPlanDetailEntity wmsInPlanDetailEntity)
{
return wmsInPlanDetailEntityMapper.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntity);
public List<WmsInPlanDetailEntity> selectWmsInPlanDetailEntityList(WmsInPlanDetailEntity wmsInPlanDetailEntity) {
List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetailEntityMapper.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntity);
List<WmsInPlanDetailEntity> handleWmsInPlanDetailEntityList = new ArrayList<>();
wmsInPlanDetailEntityList.forEach(entity -> {
// 获取入库计划信息
WmsInPlan wmsInPlan = wmsInPlanMapper.selectWmsInPlanByPlanId(entity.getPlanId().toString());
// 获取入库计划
WmsBusinessType wmsBusinessType = wmsBusinessTypeMapper.selectWmsBusinessTypeByTypeId(wmsInPlan.getPlanTypeId());
for (WmsInPlanDetails detail : wmsInPlan.getWmsInPlanDetailsList()) {
// 匹配入库明细
if (detail.getDetailsId().equals(entity.getPlanDetailsId())) {
System.out.println("---" + detail.getDetailsId() + "+测试+" + entity.getPlanDetailsId());
WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(detail.getCellId());
entity.setDetailBatch(detail.getBatch());
// 设置库位信息
entity.setCellCode(wmStorageArea.getAreaCode());
entity.setCellName(wmStorageArea.getAreaName());
}
}
entity.setPlanCode(wmsInPlan.getPlanCode());
entity.setPlanType(wmsBusinessType.getName());
entity.setPlanState(wmsInPlan.getState());
entity.setPlanSourceType(wmsInPlan.getSourceType());
handleWmsInPlanDetailEntityList.add(entity);
});
return handleWmsInPlanDetailEntityList;
}
/**
* 新增入库计划明细实体
*
*
* @param wmsInPlanDetailEntity 入库计划明细实体
* @return 结果
*/
@Override
public int insertWmsInPlanDetailEntity(WmsInPlanDetailEntity wmsInPlanDetailEntity)
{
public int insertWmsInPlanDetailEntity(WmsInPlanDetailEntity wmsInPlanDetailEntity) {
wmsInPlanDetailEntity.setCreateTime(DateUtils.getNowDate());
return wmsInPlanDetailEntityMapper.insertWmsInPlanDetailEntity(wmsInPlanDetailEntity);
}
/**
* 修改入库计划明细实体
*
*
* @param wmsInPlanDetailEntity 入库计划明细实体
* @return 结果
*/
@Override
public int updateWmsInPlanDetailEntity(WmsInPlanDetailEntity wmsInPlanDetailEntity)
{
public int updateWmsInPlanDetailEntity(WmsInPlanDetailEntity wmsInPlanDetailEntity) {
wmsInPlanDetailEntity.setUpdateTime(DateUtils.getNowDate());
return wmsInPlanDetailEntityMapper.updateWmsInPlanDetailEntity(wmsInPlanDetailEntity);
}
/**
* 批量删除入库计划明细实体
*
*
* @param ids 需要删除的入库计划明细实体主键
* @return 结果
*/
@Override
public int deleteWmsInPlanDetailEntityByIds(Long[] ids)
{
public int deleteWmsInPlanDetailEntityByIds(Long[] ids) {
return wmsInPlanDetailEntityMapper.deleteWmsInPlanDetailEntityByIds(ids);
}
/**
* 删除入库计划明细实体信息
*
*
* @param id 入库计划明细实体主键
* @return 结果
*/
@Override
public int deleteWmsInPlanDetailEntityById(Long id)
{
public int deleteWmsInPlanDetailEntityById(Long id) {
return wmsInPlanDetailEntityMapper.deleteWmsInPlanDetailEntityById(id);
}
}

View File

@ -39,7 +39,17 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService {
*/
@Override
public WmsInPlan selectWmsInPlanByPlanId(String planId) {
return wmsInPlanMapper.selectWmsInPlanByPlanId(planId);
WmsInPlan wmsInPlan = wmsInPlanMapper.selectWmsInPlanByPlanId(planId);
List<WmsInPlanDetails> wmsInPlanDetailsList = new ArrayList<>();
wmsInPlan.getWmsInPlanDetailsList().forEach(detail -> {
WmsInPlanDetailEntity wmsInPlanDetailEntityQuery = new WmsInPlanDetailEntity();
wmsInPlanDetailEntityQuery.setPlanDetailsId(detail.getDetailsId());
List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetailEntityMapper.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntityQuery);
detail.setWmsInPlanDetailEntityList(wmsInPlanDetailEntityList);
wmsInPlanDetailsList.add(detail);
});
wmsInPlan.setWmsInPlanDetailsList(wmsInPlanDetailsList);
return wmsInPlan;
}
@Override
@ -123,15 +133,14 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService {
List<WmsInPlanDetails> wmsInPlanDetailsList = wmsInPlan.getWmsInPlanDetailsList();
Long planId = wmsInPlan.getPlanId();
if (StringUtils.isNotNull(wmsInPlanDetailsList)) {
List<WmsInPlanDetails> list = new ArrayList<WmsInPlanDetails>();
List<WmsInPlanDetails> list = new ArrayList<>();
for (WmsInPlanDetails wmsInPlanDetails : wmsInPlanDetailsList) {
wmsInPlanDetails.setPlanId(planId);
list.add(wmsInPlanDetails);
}
if (!list.isEmpty()) {
wmsInPlanMapper.batchWmsInPlanDetails(list);
WmsInPlan wmsInPlan1 = wmsInPlanMapper.selectWmsInPlanByPlanId(planId.toString());
WmsInPlan wmsInPlan1 = selectWmsInPlanByPlanId(planId.toString());
List<WmsInPlanDetails> wmsInPlanDetailsList1 = wmsInPlan1.getWmsInPlanDetailsList();
for (int i = 0; i < list.size(); i++) {
List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = list.get(i).getWmsInPlanDetailEntityList();
@ -166,4 +175,13 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService {
}
}
}
/**
* 入库计划ID是否重复
* @param planCode 入库计划ID
* @return 是否重复
*/
public Boolean isDuplicatePlanCode(String planCode) {
return wmsInPlanMapper.isDuplicatePlanCode(planCode);
}
}

View File

@ -1,13 +1,33 @@
package com.ktg.mes.wm.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.utils.DateUtils;
import com.ktg.generator.util.MultiModuleCodeGenerator;
import com.ktg.mes.md.domain.*;
import com.ktg.mes.md.mapper.*;
import com.ktg.mes.md.service.IBaseKnifeService;
import com.ktg.mes.md.service.IBaseTechnologyBomService;
import com.ktg.mes.md.service.IBomRouteService;
import com.ktg.mes.md.service.IMdItemService;
import com.ktg.mes.wm.domain.*;
import com.ktg.mes.wm.mapper.WmStorageAreaMapper;
import com.ktg.mes.wm.mapper.WmsInPlanMapper;
import com.ktg.mes.wm.mapper.WmsInTaskMapper;
import com.ktg.mes.wm.service.IWmStorageAreaService;
import com.ktg.mes.wm.service.IWmsInPlanService;
import com.ktg.mes.wm.service.IWmsInTaskService;
import com.ktg.system.mapper.SysOperLogMapper;
import com.ktg.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktg.mes.wm.mapper.WmsZdTaskMapper;
import com.ktg.mes.wm.domain.WmsZdTask;
import com.ktg.mes.wm.service.IWmsZdTaskService;
import static com.ktg.common.utils.SecurityUtils.getUsername;
import static com.ktg.generator.util.MultiModuleCodeGenerator.generateTaskCode;
import static org.apache.commons.lang3.SystemUtils.getUserName;
/**
@ -19,9 +39,39 @@ import static org.apache.commons.lang3.SystemUtils.getUserName;
@Service
public class WmsZdTaskServiceImpl implements IWmsZdTaskService
{
@Autowired
private BaseKnifeMapper baseKnifeMapper;
@Autowired
private BomRouteMapper bomRouteMapper;
@Autowired
private MdItemMapper mdItemMapper;
@Autowired
private BaseTechnologyBomMapper baseTechnologyBomMapper;
@Autowired
private WmsZdTaskMapper wmsZdTaskMapper;
@Autowired
private WmStorageAreaMapper wmStorageAreaMapper;
@Autowired
private WmsInPlanMapper wmsInPlanMapper;
@Autowired
private WmsInTaskMapper wmsInTaskMapper;
@Autowired
private WmsOutPlanMapper wmsOutPlanMapper;
@Autowired
private WmsOutPlanDetailEntityMapper wmsOutPlanDetailEntityMapper;
@Autowired
private WmsOutTaskMapper wmsOutTaskMapper;
/**
* 查询组装任务
*
@ -97,4 +147,243 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
{
return wmsZdTaskMapper.deleteWmsZdTaskByWmsZdTaskId(wmsZdTaskId);
}
@Override
public AjaxResult createOutTaskByWmsZdTask(WmsZdTask zdTask) {
String batchNum = "ZZPC001";
// 判断物料是否充足
BomRoute bomRoute = bomRouteMapper.selectBomRouteByBomRouteId(zdTask.getAttr1());
BaseKnife baseKnifeWrapper = new BaseKnife();
List<BaseKnife> baseKnifeList = new ArrayList<>();
// 遍历组装整刀需要的bom物料
for (MbbProduBom mbbProduBom : bomRoute.getMbbProduBomList()) {
// 查找未锁定的物料
baseKnifeWrapper.setMbbBdMrlId(mbbProduBom.getMdItemId());
baseKnifeWrapper.setIsLocked(0);
baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
// 如果未锁定的物料不足所需数量
if (baseKnifeList.size() < mbbProduBom.getStandardDosage() * zdTask.getProductIdQty())
return AjaxResult.error("bom物料不足进行组装" + mbbProduBom.getMdItemCode());
}
List<WmsOutPlanDetail> wmsOutPlanDetailList = new ArrayList<>();
List<BaseKnife> baseKnifeListOutPlan = new ArrayList<>();
BaseTechnologyBom technologyBom = new BaseTechnologyBom();
// 出库基础物料 根据图号查询出库计划如果不存在生成计划存在则往计划中添加任务
WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(zdTask.getAttr4());
if (outPlan == null){
// 构建新的出库计划
WmsOutPlan outPlanTemp = new WmsOutPlan();
outPlanTemp.setPlanCode(zdTask.getAttr4() == null ? zdTask.getCode() : zdTask.getAttr4());
outPlanTemp.setWmsBusinessTypeId(12L);
outPlanTemp.setPlanState("1");
outPlanTemp.setPlanType("ZDCK");
outPlanTemp.setCreateBy(getUsername());
outPlanTemp.setCreateTime(DateUtils.getNowDate());
wmsOutPlanMapper.insertWmsOutPlan(outPlanTemp);
outPlan = outPlanTemp;
}
// 出库任务
for (MbbProduBom mbbProduBom : bomRoute.getMbbProduBomList()) {
// 出库任务进行基础物料的出库
MdItem mdItemOutPlan = mdItemMapper.selectMdItemById(mbbProduBom.getMdItemId());
WmsOutPlanDetail outPlanDetail = new WmsOutPlanDetail();
outPlanDetail.setWmsOutPlanId(outPlan.getWmsOutPlanId());
outPlanDetail.setMdItemId(mbbProduBom.getMdItemId());
outPlanDetail.setMdItemCode(mdItemOutPlan.getItemCode());
outPlanDetail.setMdItemName(mdItemOutPlan.getItemName());
outPlanDetail.setMdItemUnit(mdItemOutPlan.getUnitName());
outPlanDetail.setPlannedQuantity(mbbProduBom.getStandardDosage() * zdTask.getProductIdQty());
outPlanDetail.setRealQuantity(mbbProduBom.getStandardDosage() * zdTask.getProductIdQty());
outPlanDetail.setDetailBatchNum(batchNum);
// 查询库位信息
WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaCode(zdTask.getAttr3());
outPlanDetail.setWmStorageAreaId(wmStorageArea.getAreaId());
outPlanDetail.setWmStorageAreaCode(wmStorageArea.getAreaCode());
outPlanDetail.setWmStorageAreaName(wmStorageArea.getAreaName());
outPlanDetail.setDetailState("1");
wmsOutPlanDetailList.add(outPlanDetail);
// 查询未锁定的物料
baseKnifeWrapper.setMbbBdMrlId(mbbProduBom.getMdItemId());
baseKnifeWrapper.setIsLocked(0);
baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
// 锁定基础 物料
int bomCount = mbbProduBom.getStandardDosage();
for (BaseKnife wmsBaseKnife : baseKnifeList){
if (bomCount > 0){
wmsBaseKnife.setIsLocked(1);
wmsBaseKnife.setKnifeFineState(2);
wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
wmsBaseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
// wmsBaseKnife.setAttr1(baseKnife.getBaseKnifeId());
wmsBaseKnife.setPlanSheet(zdTask.getAttr4());
baseKnifeListOutPlan.add(wmsBaseKnife);
baseKnifeMapper.updateBaseKnife(wmsBaseKnife);
bomCount--;
}
}
}
// 出库
int i = 0;
for (WmsOutPlanDetail outPlanDetail : wmsOutPlanDetailList){
wmsOutPlanMapper.insertWmsOutPlanDetail(outPlanDetail);
// 出库计划明细绑定实体
for (int j = 0; j < outPlanDetail.getPlannedQuantity(); j++) {
WmsOutPlanDetailEntity wmsOutPlanDetailEntity = new WmsOutPlanDetailEntity();
wmsOutPlanDetailEntity.setBaseKnifeId(baseKnifeListOutPlan.get(i).getBaseKnifeId());
wmsOutPlanDetailEntity.setAreaCode(baseKnifeListOutPlan.get(i).getAreaCode());
wmsOutPlanDetailEntity.setItemOrProduct(baseKnifeListOutPlan.get(i).getItemOrProduct());
wmsOutPlanDetailEntity.setKnifeCode(baseKnifeListOutPlan.get(i).getKnifeCode());
wmsOutPlanDetailEntity.setKnifeName(baseKnifeListOutPlan.get(i).getKnifeName());
wmsOutPlanDetailEntity.setPlanSheet(baseKnifeListOutPlan.get(i).getPlanSheet());
wmsOutPlanDetailEntity.setKnifeLife(baseKnifeListOutPlan.get(i).getKnifeLife());
wmsOutPlanDetailEntity.setResetCount(baseKnifeListOutPlan.get(i).getResetCount());
wmsOutPlanDetailEntity.setKnifeUnit(baseKnifeListOutPlan.get(i).getKnifeUnit());
wmsOutPlanDetailEntity.setSafeStock(baseKnifeListOutPlan.get(i).getKnifeType());
wmsOutPlanDetailEntity.setStandardQuantity(baseKnifeListOutPlan.get(i++).getStandardQuantity());
wmsOutPlanDetailEntity.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
wmsOutPlanDetailEntity.setCreateBy(getUsername());
wmsOutPlanDetailEntity.setCreateTime(DateUtils.getNowDate());
wmsOutPlanDetailEntityMapper.insertWmsOutPlanDetailEntity(wmsOutPlanDetailEntity);
}
// 生成出库任务
WmsOutTask wmsOutTask = new WmsOutTask();
wmsOutTask.setWmsOutPlanId(outPlan.getWmsOutPlanId());
wmsOutTask.setWmsOutPlanCode(outPlan.getPlanCode());
wmsOutTask.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
// 出库类型 12组刀出库
wmsOutTask.setWmsBusinessTypeId(12L);
wmsOutTask.setTaskCode(generateTaskCode(outPlan.getPlanCode()));
wmsOutTask.setTaskNumber(outPlanDetail.getPlannedQuantity());
wmsOutTask.setOutNumber(outPlanDetail.getRealQuantity());
wmsOutTask.setWmStorageAreaId(outPlanDetail.getWmStorageAreaId());
wmsOutTask.setBatchNum(batchNum);
wmsOutTask.setMdItemId(outPlanDetail.getMdItemId());
wmsOutTask.setMdItemCode(outPlanDetail.getMdItemCode());
wmsOutTask.setMdItemName(outPlanDetail.getMdItemName());
wmsOutTask.setMdItemUnit(outPlanDetail.getMdItemUnit());
wmsOutTask.setTaskState("1");
wmsOutTask.setRecipientUsername("");
wmsOutTask.setCreateBy(getUsername());
wmsOutTask.setCreateTime(DateUtils.getNowDate());
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
}
// 更新组装任务
zdTask.setStatus("1");
zdTask.setQtyOk(zdTask.getProductIdQty());
wmsZdTaskMapper.updateWmsZdTask(zdTask);
return AjaxResult.success();
}
@Override
public AjaxResult createInTaskByWmsZdTask(WmsZdTask zdTask) {
String batchNum = "ZZPC001";
BaseTechnologyBom technologyBom = new BaseTechnologyBom();
for (int i = 0; i < zdTask.getProductIdQty(); i++) {
// 构建整刀
BaseKnife baseKnife = new BaseKnife();
MdItem mdItem = mdItemMapper.selectMdItemById(zdTask.getmProductId());
baseKnife.setMbbBdMrlId(zdTask.getmProductId());
baseKnife.setKnifeCode(mdItem.getItemCode());
baseKnife.setKnifeName(mdItem.getItemName());
baseKnife.setKnifeUnit(mdItem.getUnitName());
baseKnife.setKnifeType(mdItem.getItemTypeName());
// attr3 库位编码
baseKnife.setAreaCode(zdTask.getAttr3());
baseKnife.setSafeStock(mdItem.getMinStock());
baseKnife.setStandardQuantity("1");
baseKnife.setKnifeLife(100);
baseKnife.setKnifeFineState(1);
// 判断是否需要锁定整刀
baseKnife.setIsLocked(1);
baseKnife.setLockedStartTime(technologyBom.getLockedStartTime());
baseKnife.setLockedEndTime(technologyBom.getLockedEndTime());
// attr4 计划编码 整刀
baseKnife.setPlanSheet(zdTask.getAttr4());
baseKnife.setItemOrProduct("PRODUCT");
baseKnife.setCreateBy(getUsername());
baseKnife.setCreateTime(DateUtils.getNowDate());
baseKnifeMapper.insertBaseKnife(baseKnife);
}
// 整刀入库计划, 根据图号查询入库计划如果不存在生成计划存在则往计划中添加任务
WmsInPlan wmsInPlan = wmsInPlanMapper.selectWmsInPlanByPlanCode(zdTask.getAttr4());
if (wmsInPlan == null){
WmsInPlan wmsInPlanTemp = new WmsInPlan();
wmsInPlanTemp.setState("1");
wmsInPlanTemp.setSourceType("SGLR");
wmsInPlanTemp.setCellCode(zdTask.getAttr3());
wmsInPlanTemp.setPlanCode(zdTask.getAttr4() == null ? zdTask.getCode() : zdTask.getAttr4());
wmsInPlanTemp.setRelBillCode("组装单据");
wmsInPlanTemp.setPlanTypeId("13");
wmsInPlanTemp.setCreateBy(getUsername());
wmsInPlanTemp.setCreateTime(DateUtils.getNowDate());
// 入库任务明细
List<WmsInPlanDetails> wmsInPlanDetailsList = new ArrayList<>();
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails();
wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString());
wmsInPlanDetails.setBatch(batchNum);
wmsInPlanDetails.setCellId(1L);
wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString());
wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString());
wmsInPlanDetails.setPlanInStatus("0");
wmsInPlanDetailsList.add(wmsInPlanDetails);
wmsInPlanTemp.setWmsInPlanDetailsList(wmsInPlanDetailsList);
wmsInPlanMapper.insertWmsInPlan(wmsInPlanTemp);
wmsInPlan = wmsInPlanTemp;
} else {
// 入库任务明细
List<WmsInPlanDetails> wmsInPlanDetailsList = wmsInPlan.getWmsInPlanDetailsList();
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails();
wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString());
wmsInPlanDetails.setBatch(batchNum);
wmsInPlanDetails.setCellId(1L);
wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString());
wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString());
wmsInPlanDetails.setPlanInStatus("0");
wmsInPlanDetailsList.add(wmsInPlanDetails);
wmsInPlan.setWmsInPlanDetailsList(wmsInPlanDetailsList);
wmsInPlanMapper.updateWmsInPlan(wmsInPlan);
}
// 入库任务
MdItem mdItem = mdItemMapper.selectMdItemById(zdTask.getmProductId());
WmsInTask wmsInTask = new WmsInTask();
wmsInTask.setTaskInCode(MultiModuleCodeGenerator.generateTaskCode("RKT"));
wmsInTask.setPlanInId(wmsInPlan.getPlanId().toString());
wmsInTask.setPlanInCode(wmsInPlan.getPlanCode());
wmsInTask.setMaterialCode(mdItem.getItemCode());
wmsInTask.setTaskInQuantity(zdTask.getProductIdQty());
wmsInTask.setActualInQuantity(zdTask.getProductIdQty());
WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaCode(zdTask.getAttr3());
wmsInTask.setCellTgt(wmStorageArea.getAreaId());
wmsInTask.setBatch(batchNum);
wmsInTask.setMaterialId(zdTask.getmProductId().toString());
wmsInTask.setPlanTypeId("9");
wmsInTask.setPlanInStatus("1");
wmsInTaskMapper.insertWmsInTask(wmsInTask);
// 更新组装任务
zdTask.setStatus("2");
zdTask.setQtyOk(zdTask.getProductIdQty());
wmsZdTaskMapper.updateWmsZdTask(zdTask);
return AjaxResult.success();
}
}

View File

@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attr3 != null "> and attr3 = #{attr3}</if>
<if test="attr4 != null "> and attr4 = #{attr4}</if>
</where>
order by create_time desc
</select>
<select id="selectMdUnitMeasureByMeasureId" parameterType="Long" resultMap="MdUnitMeasureResult">

View File

@ -88,7 +88,6 @@
PLAN_CODE,
PLAN_TYPE_ID
from WMS_IN_PLAN
order by CREATE_TIME desc
</sql>
<select id="selectWmsInPlanList" parameterType="WmsInPlan" resultMap="WmsInPlanResult">
@ -124,6 +123,7 @@
<if test="planCode != null and planCode != ''">and PLAN_CODE = #{planCode}</if>
<if test="planTypeId != null and planTypeId != ''">and PLAN_TYPE_ID = #{planTypeId}</if>
</where>
order by CREATE_TIME desc
</select>
<select id="selectWmsInPlanByPlanId" parameterType="String" resultMap="WmsInPlanWmsInPlanDetailsResult">
@ -355,4 +355,10 @@
#{item.updateTime}, #{item.isActivy}, #{item.isDelete})
</foreach>
</insert>
<select id="isDuplicatePlanCode" parameterType="String" resultType="boolean">
SELECT COUNT(1)
FROM WMS_IN_PLAN
WHERE PLAN_CODE = #{value}
</select>
</mapper>

View File

@ -52,8 +52,8 @@
a.PLAN_IN_CODE,
a.MATERIAL_CODE,
a.DETAIL_IN_ID,
b.AREA_CODE AS CELL_CODE,
b.AREA_NAME AS CELL_NAME
b.AREA_CODE as CELL_CODE,
b.AREA_NAME as CELL_NAME
from WMS_IN_TASK a
left join WM_STORAGE_AREA b on b.AREA_ID = a.CELL_TGT
</sql>
@ -84,6 +84,7 @@
<if test="materialCode != null and materialCode != ''">and MATERIAL_CODE = #{materialCode}</if>
<if test="detailInId != null and detailInId != ''">and DETAIL_IN_ID = #{detailInId}</if>
</where>
order by a.CREATE_TIME desc
</select>
<select id="selectWmsInTaskById" parameterType="String" resultMap="WmsInTaskResult">

View File

@ -82,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by u.create_time desc
</select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">