完成上传接口
This commit is contained in:
parent
d4029665a1
commit
e936e8e613
@ -9,9 +9,12 @@ import com.ktg.common.enums.BusinessType;
|
||||
import com.ktg.common.utils.poi.ExcelUtil;
|
||||
import com.ktg.mes.md.domain.BaseKnife;
|
||||
import com.ktg.mes.md.mapper.BaseKnifeMapper;
|
||||
import com.ktg.mes.md.mapper.UcmCtMaterialMapper2;
|
||||
import com.ktg.mes.wm.domain.UcmCtBase;
|
||||
import com.ktg.mes.wm.domain.UcmCtMaterial;
|
||||
import com.ktg.mes.wm.domain.box.Box;
|
||||
import com.ktg.mes.wm.domain.box.BoxItem;
|
||||
import com.ktg.mes.wm.mapper.UcmCtBaseMapper;
|
||||
import com.ktg.mes.wm.service.IUcmCtBaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -61,11 +65,11 @@ public class UcmCtBaseController extends BaseController {
|
||||
public String uploadBox(
|
||||
@RequestBody List<Box> boxList
|
||||
) {
|
||||
boxList.forEach(box -> {
|
||||
System.out.println(JSON.toJSONString(box));
|
||||
});
|
||||
|
||||
return "失败,正在调试中...";
|
||||
try {
|
||||
return ucmCtBaseService.bindAndUnbindUcmCtBase(boxList);
|
||||
} catch (Exception e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ktg.mes.wm.service;
|
||||
|
||||
import com.ktg.mes.wm.domain.UcmCtBase;
|
||||
import com.ktg.mes.wm.domain.box.Box;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -63,4 +64,6 @@ public interface IUcmCtBaseService
|
||||
int bindUcmCtBase(String boxCode, String itemCode);
|
||||
|
||||
int unbindUcmCtBase(String boxCode, String itemCode);
|
||||
|
||||
String bindAndUnbindUcmCtBase(List<Box> boxList);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import com.ktg.mes.md.mapper.BaseKnifeMapper;
|
||||
import com.ktg.mes.md.mapper.UcmCtMaterialMapper2;
|
||||
import com.ktg.mes.wm.domain.UcmCtBase;
|
||||
import com.ktg.mes.wm.domain.UcmCtMaterial;
|
||||
import com.ktg.mes.wm.domain.box.Box;
|
||||
import com.ktg.mes.wm.domain.box.BoxItem;
|
||||
import com.ktg.mes.wm.mapper.UcmCtBaseMapper;
|
||||
import com.ktg.mes.wm.service.IUcmCtBaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -142,7 +144,7 @@ public class UcmCtBaseServiceImpl implements IUcmCtBaseService {
|
||||
ucmCtMaterialQuery.setBaseKnifeId(baseKnifeList.get(0).getBaseKnifeId());
|
||||
List<UcmCtMaterial> ucmCtMaterialList = ucmCtMaterialMapper2.selectUcmCtMaterialList(ucmCtMaterialQuery);
|
||||
if (!ucmCtMaterialList.isEmpty())
|
||||
throw new RuntimeException("解绑失败,该物料已经绑定该料箱");
|
||||
throw new RuntimeException("绑定失败,该物料已经绑定该料箱");
|
||||
|
||||
UcmCtMaterial ucmCtMaterial = new UcmCtMaterial();
|
||||
ucmCtMaterial.setCtBaseId(Long.parseLong(ucmCtBaseList.get(0).getCtBaseId()));
|
||||
@ -181,4 +183,65 @@ public class UcmCtBaseServiceImpl implements IUcmCtBaseService {
|
||||
|
||||
return ucmCtMaterialList.size();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public String bindAndUnbindUcmCtBase(List<Box> boxList) {
|
||||
for (Box box : boxList) {
|
||||
if (!box.getIsUnbind()) {
|
||||
for (BoxItem boxItem : box.getBoxItemList()) {
|
||||
UcmCtBase ucmCtBaseQuery = new UcmCtBase();
|
||||
ucmCtBaseQuery.setCode(box.getBoxRfid().trim());
|
||||
List<UcmCtBase> ucmCtBaseList = ucmCtBaseMapper.selectUcmCtBaseList(ucmCtBaseQuery);
|
||||
if (ucmCtBaseList.isEmpty())
|
||||
throw new RuntimeException(String.format("绑定失败,料箱“%s”不存在", box.getBoxRfid().trim()));
|
||||
|
||||
BaseKnife baseKnifeQuery = new BaseKnife();
|
||||
baseKnifeQuery.setRfid(boxItem.getBoxItemRfid().trim());
|
||||
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeQuery);
|
||||
if (baseKnifeList.isEmpty())
|
||||
throw new RuntimeException(String.format("绑定失败,物料“%s”不存在", boxItem.getBoxItemRfid().trim()));
|
||||
|
||||
UcmCtMaterial ucmCtMaterialQuery = new UcmCtMaterial();
|
||||
ucmCtMaterialQuery.setCtBaseId(Long.parseLong(ucmCtBaseList.get(0).getCtBaseId()));
|
||||
ucmCtMaterialQuery.setBaseKnifeId(baseKnifeList.get(0).getBaseKnifeId());
|
||||
List<UcmCtMaterial> ucmCtMaterialList = ucmCtMaterialMapper2.selectUcmCtMaterialList(ucmCtMaterialQuery);
|
||||
if (!ucmCtMaterialList.isEmpty())
|
||||
throw new RuntimeException(String.format("绑定失败,物料“%s”已经绑定料箱“%s”", boxItem.getBoxItemRfid().trim(), box.getBoxRfid().trim()));
|
||||
|
||||
UcmCtMaterial ucmCtMaterial = new UcmCtMaterial();
|
||||
ucmCtMaterial.setCtBaseId(Long.parseLong(ucmCtBaseList.get(0).getCtBaseId()));
|
||||
ucmCtMaterial.setBaseKnifeId(baseKnifeList.get(0).getBaseKnifeId());
|
||||
ucmCtMaterial.setCreateTime(new Date(System.currentTimeMillis()));
|
||||
ucmCtMaterialMapper2.insertUcmCtMaterial(ucmCtMaterial);
|
||||
}
|
||||
} else {
|
||||
for (BoxItem boxItem : box.getBoxItemList()) {
|
||||
UcmCtBase ucmCtBaseQuery = new UcmCtBase();
|
||||
ucmCtBaseQuery.setCode(box.getBoxRfid().trim());
|
||||
List<UcmCtBase> ucmCtBaseList = ucmCtBaseMapper.selectUcmCtBaseList(ucmCtBaseQuery);
|
||||
if (ucmCtBaseList.isEmpty())
|
||||
throw new RuntimeException(String.format("解绑失败,料箱“%s”不存在", box.getBoxRfid().trim()));
|
||||
|
||||
BaseKnife baseKnifeQuery = new BaseKnife();
|
||||
baseKnifeQuery.setRfid(boxItem.getBoxItemRfid().trim());
|
||||
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeQuery);
|
||||
if (baseKnifeList.isEmpty())
|
||||
throw new RuntimeException(String.format("解绑失败,物料“%s”不存在", boxItem.getBoxItemRfid().trim()));
|
||||
|
||||
UcmCtMaterial ucmCtMaterialQuery = new UcmCtMaterial();
|
||||
ucmCtMaterialQuery.setCtBaseId(Long.parseLong(ucmCtBaseList.get(0).getCtBaseId()));
|
||||
ucmCtMaterialQuery.setBaseKnifeId(baseKnifeList.get(0).getBaseKnifeId());
|
||||
List<UcmCtMaterial> ucmCtMaterialList = ucmCtMaterialMapper2.selectUcmCtMaterialList(ucmCtMaterialQuery);
|
||||
if (ucmCtMaterialList.isEmpty())
|
||||
throw new RuntimeException(String.format("解绑失败,物料“%s”并未绑定料箱“%s”", boxItem.getBoxItemRfid().trim(), box.getBoxRfid().trim()));
|
||||
|
||||
ucmCtMaterialList.forEach(item -> {
|
||||
ucmCtMaterialMapper2.deleteUcmCtMaterialByCtMaterialId(item.getCtMaterialId());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user