add:查看取消需求单
This commit is contained in:
@@ -29,34 +29,41 @@
|
||||
select d.*,g.qty pkInv
|
||||
from pm_demand d
|
||||
left join md_pb_groupplate g on d.sku_code = g.material_code and g.storagevehicle_code = 'VTP0006'
|
||||
where is_deleted = 0
|
||||
<if test="query.id != null and query.id != ''">
|
||||
and d.id = #{query.id}
|
||||
</if>
|
||||
<if test="query.creator != null and query.creator != ''">
|
||||
and d.creator like concat('%', #{query.creator}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
and d.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.workOrder != null and query.workOrder != ''">
|
||||
and d.work_order like concat('%', #{query.workOrder}, '%')
|
||||
</if>
|
||||
<if test="query.skuCode != null and query.skuCode != ''">
|
||||
and (d.sku_code like concat('%', #{query.skuCode}, '%') or d.sku_name like concat('%', #{query.skuCode}, '%'))
|
||||
</if>
|
||||
<if test="query.productionLine != null and query.productionLine != ''">
|
||||
and d.production_line like concat('%', #{query.productionLine}, '%')
|
||||
</if>
|
||||
<if test="query.targetArea != null and query.targetArea != ''">
|
||||
and d.target_area like concat('%', #{query.targetArea}, '%')
|
||||
</if>
|
||||
<if test="query.startTime != null and query.startTime != ''">
|
||||
and d.create_time >= #{query.startTime}
|
||||
</if>
|
||||
<if test="query.endTime != null and query.endTime != ''">
|
||||
and d.create_time <= #{query.endTime}
|
||||
</if>
|
||||
where 1 = 1
|
||||
<if test="query.status == 90">
|
||||
and is_deleted = 1
|
||||
</if>
|
||||
<if test="query.status != 90">
|
||||
and is_deleted = 0
|
||||
</if>
|
||||
<if test="query.id != null and query.id != ''">
|
||||
and d.id = #{query.id}
|
||||
</if>
|
||||
<if test="query.creator != null and query.creator != ''">
|
||||
and d.creator like concat('%', #{query.creator}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
and d.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.workOrder != null and query.workOrder != ''">
|
||||
and d.work_order like concat('%', #{query.workOrder}, '%')
|
||||
</if>
|
||||
<if test="query.skuCode != null and query.skuCode != ''">
|
||||
and (d.sku_code like concat('%', #{query.skuCode}, '%') or d.sku_name like concat('%', #{query.skuCode},
|
||||
'%'))
|
||||
</if>
|
||||
<if test="query.productionLine != null and query.productionLine != ''">
|
||||
and d.production_line like concat('%', #{query.productionLine}, '%')
|
||||
</if>
|
||||
<if test="query.targetArea != null and query.targetArea != ''">
|
||||
and d.target_area like concat('%', #{query.targetArea}, '%')
|
||||
</if>
|
||||
<if test="query.startTime != null and query.startTime != ''">
|
||||
and d.create_time >= #{query.startTime}
|
||||
</if>
|
||||
<if test="query.endTime != null and query.endTime != ''">
|
||||
and d.create_time <= #{query.endTime}
|
||||
</if>
|
||||
order by d.seq_no asc,d.priority desc, d.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -128,18 +128,18 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
@Override
|
||||
public void batchCreate(List<PmDemandParam> param) {
|
||||
final List<String> orders = param.stream()
|
||||
.filter(item-> !Objects.equals(item.getStatus(), "1"))
|
||||
.filter(item -> !Objects.equals(item.getStatus(), "1"))
|
||||
.map(PmDemandParam::getWorkOrder).collect(Collectors.toList());
|
||||
if (!orders.isEmpty()){
|
||||
if (!orders.isEmpty()) {
|
||||
final int count = this.count(new LambdaQueryWrapper<PmDemand>()
|
||||
.in(PmDemand::getWork_order, orders)
|
||||
.eq(PmDemand::getIs_deleted,0));
|
||||
if (count>0){
|
||||
.eq(PmDemand::getIs_deleted, 0));
|
||||
if (count > 0) {
|
||||
throw new BadRequestException("MES推送需求单失败,需求单已存在");
|
||||
}
|
||||
}
|
||||
for (PmDemandParam pmDemandParam : param) {
|
||||
if (Objects.equals(pmDemandParam.getStatus(), "1")){
|
||||
if (Objects.equals(pmDemandParam.getStatus(), "1")) {
|
||||
pmDemandParam.setStatus(DemandStatus.CANCEL.getValue());
|
||||
PmDemand demand = new PmDemand();
|
||||
demand.setId(pmDemandParam.getId());
|
||||
@@ -157,7 +157,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
demand.setProduction_line(pmDemandParam.getProductionLine());
|
||||
demand.setSn(pmDemandParam.getSn());
|
||||
this.updateById(demand);
|
||||
}else{
|
||||
} else {
|
||||
this.create(pmDemandParam);
|
||||
}
|
||||
}
|
||||
@@ -196,15 +196,16 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
final List<PmDemand> pmDemands = this.listByIds(ids);
|
||||
for (PmDemand pmDemand : pmDemands) {
|
||||
if (!pmDemand.getStatus().equals(DemandStatus.CREATE.getValue())
|
||||
&& !pmDemand.getStatus().equals(DemandStatus.DIS.getValue())){
|
||||
&& !pmDemand.getStatus().equals(DemandStatus.DIS.getValue())) {
|
||||
throw new BadRequestException("删除失败,已经执行的需求单无法删除");
|
||||
}
|
||||
}
|
||||
for (String id : ids) {
|
||||
mesApi.delMesDemand(id);
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.eq(PmDemand::getId,id)
|
||||
.set(PmDemand::getIs_deleted,1));
|
||||
.eq(PmDemand::getId, id)
|
||||
.set(PmDemand::getStatus, DemandStatus.CANCEL.getValue())
|
||||
.set(PmDemand::getIs_deleted, 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +218,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
if (demand == null) {
|
||||
throw new BadRequestException("需求单不存在");
|
||||
}
|
||||
if (Objects.equals(demand.getStatus(), DemandStatus.FINISH.getValue())){
|
||||
if (Objects.equals(demand.getStatus(), DemandStatus.FINISH.getValue())) {
|
||||
throw new BadRequestException("单据已完成不允许分配");
|
||||
}
|
||||
demand.setInventory_dis(inventoryDis);
|
||||
@@ -258,7 +259,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
demandDto.setHouseName(dto.getStorName());
|
||||
resultList.add(demandDto);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
DemandInventryDto demandDto = new DemandInventryDto();
|
||||
demandDto.setSkuCode(skuCode);
|
||||
demandDto.setQty(BigDecimal.ZERO);
|
||||
@@ -275,14 +276,14 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
demandDto.setQty(item.getQty());
|
||||
//中鼎库存有映射
|
||||
String houseMapping = WmsToZDWmdService.ZD_LOS_MAPPING.get(item.getHouseCode());
|
||||
if (StringUtils.isEmpty(houseMapping)){
|
||||
if (StringUtils.isEmpty(houseMapping)) {
|
||||
throw new BadRequestException("分配失败,当前中鼎仓库编码未配置映射");
|
||||
}
|
||||
demandDto.setHouseCode(houseMapping);
|
||||
demandDto.setHouseName("五期原材料立库6.002");
|
||||
resultList.add(demandDto);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
DemandInventryDto demandDto = new DemandInventryDto();
|
||||
demandDto.setSkuCode(skuCode);
|
||||
demandDto.setSkuName(null);
|
||||
@@ -291,26 +292,26 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
demandDto.setHouseName("五期原材料立库6.002");
|
||||
resultList.add(demandDto);
|
||||
}
|
||||
return resultList.stream().filter(i-> !i.getHouseName().contains("线边库")).collect(Collectors.toList());
|
||||
return resultList.stream().filter(i -> !i.getHouseName().contains("线边库")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void pushDemand(List<PmDemandDto> pmDemandDtos) {
|
||||
if (CollectionUtils.isEmpty(pmDemandDtos)){
|
||||
if (CollectionUtils.isEmpty(pmDemandDtos)) {
|
||||
throw new BadRequestException("下推失败,请求数据不能为空");
|
||||
}
|
||||
List<PmDemand> disList = this.list(new LambdaQueryWrapper<PmDemand>()
|
||||
.in(PmDemand::getId, pmDemandDtos.stream().map(PmDemandDto::getId).collect(Collectors.toList()))
|
||||
.eq(PmDemand::getStatus, DemandStatus.DIS.getValue())
|
||||
.ne(PmDemand::getIs_deleted, 1));
|
||||
if (disList.size()<pmDemandDtos.size()){
|
||||
if (disList.size() < pmDemandDtos.size()) {
|
||||
String collect = pmDemandDtos.stream()
|
||||
.map(PmDemandDto::getWorkOrder)
|
||||
.filter(workOrder -> disList.stream()
|
||||
.noneMatch(i -> Objects.equals(i.getWork_order(), workOrder)))
|
||||
.collect(Collectors.joining(","));
|
||||
throw new BadRequestException("下推失败,单据"+collect+"状态不为已分配不能下推");
|
||||
throw new BadRequestException("下推失败,单据" + collect + "状态不为已分配不能下推");
|
||||
}
|
||||
List<PmDemand> allWorkDemand = this.list(new LambdaQueryWrapper<PmDemand>()
|
||||
.in(PmDemand::getWork_order, pmDemandDtos.stream()
|
||||
@@ -318,7 +319,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
.distinct()
|
||||
.collect(Collectors.toList()))
|
||||
.ne(PmDemand::getIs_deleted, 1));
|
||||
if (pmDemandDtos.size() < allWorkDemand.size()){
|
||||
if (pmDemandDtos.size() < allWorkDemand.size()) {
|
||||
String collect = allWorkDemand.stream().map(PmDemand::getWork_order)
|
||||
.filter(workOrder -> pmDemandDtos.stream().noneMatch(i -> !Objects.equals(i.getWorkOrder(), workOrder)))
|
||||
.collect(Collectors.joining(","));
|
||||
@@ -327,7 +328,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
// 一次性分成两组
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
if (zdStorParam!=null){
|
||||
if (zdStorParam != null) {
|
||||
ZD_STOR_SET = JSONObject.parseObject(zdStorParam.getValue(), List.class);
|
||||
} else {
|
||||
ZD_STOR_SET = new ArrayList<>();
|
||||
@@ -341,8 +342,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
JSONObject billParam = convertDemandsToBillParam(otherDemands);
|
||||
iOutBillService.saveBill(billParam);
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getStatus,DemandStatus.SEND.getValue())
|
||||
.in(PmDemand::getId,otherDemands.stream()
|
||||
.set(PmDemand::getStatus, DemandStatus.SEND.getValue())
|
||||
.in(PmDemand::getId, otherDemands.stream()
|
||||
.map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(zdDemands)) {
|
||||
@@ -355,8 +356,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
.eq(PmDemand::getWork_order, workOrder)
|
||||
.in(PmDemand::getInventory_dis, ZD_STOR_SET)
|
||||
.ne(PmDemand::getIs_deleted, 1));
|
||||
if (orderCount > demandDtos.size()){
|
||||
throw new BadRequestException("工单"+workOrder+"下推中鼎失败,存在未勾选的单子");
|
||||
if (orderCount > demandDtos.size()) {
|
||||
throw new BadRequestException("工单" + workOrder + "下推中鼎失败,存在未勾选的单子");
|
||||
}
|
||||
List<PmDemandDto> zd = new ArrayList<>();
|
||||
List<AddInvParam> addInvParams = new ArrayList<>();
|
||||
@@ -379,7 +380,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
addInvParam.setRemark("中鼎需求单变动");
|
||||
addInvParams.add(addInvParam);
|
||||
InFinishParam inFinishParam = new InFinishParam();
|
||||
BeanUtils.copyProperties(addInvParam,inFinishParam);
|
||||
BeanUtils.copyProperties(addInvParam, inFinishParam);
|
||||
inFinishParams.add(inFinishParam);
|
||||
zd.add(zdDemand);
|
||||
}
|
||||
@@ -388,11 +389,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getStatus,DemandStatus.FINISH.getValue())
|
||||
.in(PmDemand::getId,demandDtos.stream()
|
||||
.set(PmDemand::getStatus, DemandStatus.FINISH.getValue())
|
||||
.in(PmDemand::getId, demandDtos.stream()
|
||||
.map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
}catch (Exception ex){
|
||||
log.error("回传中鼎成功,WMS库存变动失败"+ex.getMessage());
|
||||
} catch (Exception ex) {
|
||||
log.error("回传中鼎成功,WMS库存变动失败" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -418,7 +419,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
.list(new LambdaQueryWrapper<MdMeMaterialbase>()
|
||||
.in(MdMeMaterialbase::getMaterial_code,
|
||||
demands.stream().map(PmDemandDto::getSkuCode).collect(Collectors.toList()))
|
||||
.select(MdMeMaterialbase::getQty_unit_id,MdMeMaterialbase::getMaterial_id, MdMeMaterialbase::getMaterial_code));
|
||||
.select(MdMeMaterialbase::getQty_unit_id, MdMeMaterialbase::getMaterial_id, MdMeMaterialbase::getMaterial_code));
|
||||
Map<String, MdMeMaterialbase> codeToIdMap = materialbases.stream()
|
||||
.collect(Collectors.toMap(
|
||||
MdMeMaterialbase::getMaterial_code, Function.identity()));
|
||||
@@ -426,8 +427,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
JSONObject detailRow = new JSONObject();
|
||||
detailRow.put("material_code", demand.getSkuCode());
|
||||
MdMeMaterialbase materialbase = codeToIdMap.get(demand.getSkuCode());
|
||||
if (materialbase == null){
|
||||
throw new BadRequestException("下推失败,"+demand.getSkuCode()+"在WMS中不存在");
|
||||
if (materialbase == null) {
|
||||
throw new BadRequestException("下推失败," + demand.getSkuCode() + "在WMS中不存在");
|
||||
}
|
||||
detailRow.put("material_id", materialbase.getMaterial_id());
|
||||
detailRow.put("qty_unit_name", demand.getUnit());
|
||||
@@ -459,17 +460,17 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
callbackData.put("type", "WMS");
|
||||
final String uuidBill = UUID.randomUUID().toString();
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("issueStorageOrgUnitNo", "01.09.14"); // 业务状态,可根据实际业务逻辑设置
|
||||
data.put("bizTypeNo", "331"); // 业务日期
|
||||
data.put("receiptStorageOrgUnitNo", "01.09.14"); // 创建人编号,从当前登录用户获取
|
||||
data.put("billNo", uuidBill); // 使用工单编号作为MES单号
|
||||
data.put("issueStorageOrgUnitNo", "01.09.14"); // 业务状态,可根据实际业务逻辑设置
|
||||
data.put("bizTypeNo", "331"); // 业务日期
|
||||
data.put("receiptStorageOrgUnitNo", "01.09.14"); // 创建人编号,从当前登录用户获取
|
||||
data.put("billNo", uuidBill); // 使用工单编号作为MES单号
|
||||
// 组装明细列表
|
||||
JSONArray entrys = new JSONArray();
|
||||
for (PmDemand pmDemand : pmDemands) {
|
||||
final SchBaseRegion region = iSchBaseRegionService.getOne(new LambdaQueryWrapper<SchBaseRegion>()
|
||||
.eq(SchBaseRegion::getRegion_code, pmDemand.getProduction_line())
|
||||
.select(SchBaseRegion::getPoint_type_explain));
|
||||
if (region==null){
|
||||
if (region == null) {
|
||||
throw new BadRequestException("当前产线未配置对应仓库编码getPoint_type_explain");
|
||||
}
|
||||
cn.hutool.json.JSONObject entry = new cn.hutool.json.JSONObject();
|
||||
@@ -490,8 +491,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
stockReturn.setRequest_data(callbackData.toString());
|
||||
iPmStockReturnService.save(stockReturn);
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getStatus,DemandStatus.FINISH.getValue())
|
||||
.in(PmDemand::getId,ids));
|
||||
.set(PmDemand::getStatus, DemandStatus.FINISH.getValue())
|
||||
.in(PmDemand::getId, ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -499,21 +500,21 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
final List<PmDemand> pmDemands = this.listByIds(ids);
|
||||
final List<PmDemand> needAllcation = new ArrayList<>();
|
||||
for (PmDemand pmDemand : pmDemands) {
|
||||
if (!pmDemand.getStatus().equals(DemandStatus.CREATE.getValue())){
|
||||
throw new BadRequestException("当前单子"+pmDemand.getWork_order()+"不是生成状态无法勾选");
|
||||
if (!pmDemand.getStatus().equals(DemandStatus.CREATE.getValue())) {
|
||||
throw new BadRequestException("当前单子" + pmDemand.getWork_order() + "不是生成状态无法勾选");
|
||||
}
|
||||
final List<DemandInventryDto> demandInventryDtos = this.queryInventory(pmDemand.getSku_code());
|
||||
final Map<String, DemandInventryDto> inventryDtoMap = demandInventryDtos.stream().collect(Collectors.toMap(DemandInventryDto::getHouseCode, Function.identity()));
|
||||
final DemandInventryDto demandInventryDto = inventryDtoMap.get("6.002");
|
||||
final DemandInventryDto pInventryDto = inventryDtoMap.get("6.011");
|
||||
if (demandInventryDto !=null && demandInventryDto.getQty()!=null && demandInventryDto.getQty().compareTo(pmDemand.getQty())>=0){
|
||||
if (demandInventryDto != null && demandInventryDto.getQty() != null && demandInventryDto.getQty().compareTo(pmDemand.getQty()) >= 0) {
|
||||
pmDemand.setInventory_dis("6.002");
|
||||
pmDemand.setStatus(DemandStatus.DIS.getValue());
|
||||
needAllcation.add(pmDemand);
|
||||
}else if (pInventryDto !=null && pInventryDto.getQty()!=null && pInventryDto.getQty().compareTo(pmDemand.getQty())>=0){
|
||||
} else if (pInventryDto != null && pInventryDto.getQty() != null && pInventryDto.getQty().compareTo(pmDemand.getQty()) >= 0) {
|
||||
pmDemand.setInventory_dis("6.011");
|
||||
pmDemand.setStatus(DemandStatus.DIS.getValue());
|
||||
}else {
|
||||
} else {
|
||||
pmDemand.setInventory_dis("库存不足请手动分配");
|
||||
}
|
||||
needAllcation.add(pmDemand);
|
||||
|
||||
Reference in New Issue
Block a user