|
|
|
@ -139,7 +139,7 @@ public class IoPurChangeService {
|
|
|
|
|
if (basicBusTypeChangeEntity.getBusBeforeTime() != null) {
|
|
|
|
|
purPlanEntity.setCreateTime(DateUtil.timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
|
purPlanEntity.setUpdateTime(DateUtil.timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
purPlanEntity.setCreateTime(purApplyEntity.getCreateTime());
|
|
|
|
|
purPlanEntity.setUpdateUser(purApplyEntity.getAuditUser());
|
|
|
|
|
}
|
|
|
|
@ -182,59 +182,66 @@ public class IoPurChangeService {
|
|
|
|
|
public void purPlanChange(PurPlanEntity purPlanEntity) {
|
|
|
|
|
|
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity;
|
|
|
|
|
|
|
|
|
|
String billNos = null;
|
|
|
|
|
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
|
|
|
|
|
PurOrderEntity purOrderEntity = new PurOrderEntity();
|
|
|
|
|
if (purPlanEntity.getStatus() == 3) {
|
|
|
|
|
//查询计划详情
|
|
|
|
|
List<PurPlanDetailEntity> purPlanDetailEntityList = purPlanDetailService.findByOrderId(purPlanEntity.getId() + "");
|
|
|
|
|
//根据供应商分组
|
|
|
|
|
Map<String, List<PurPlanDetailEntity>> purPlanDetailMap = purPlanDetailEntityList.stream().collect(Collectors.groupingBy(PurPlanDetailEntity::getSupId));
|
|
|
|
|
basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction("CGJH");
|
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
|
purOrderEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.CG_ORDER, "yyyyMMdd")));
|
|
|
|
|
purOrderEntity.setBillDate(purPlanEntity.getBillDate());
|
|
|
|
|
purOrderEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
|
|
|
|
|
purOrderEntity.setRemark(purPlanEntity.getRemark());
|
|
|
|
|
purOrderEntity.setEmergency(purPlanEntity.getEmergency());
|
|
|
|
|
purOrderEntity.setArrivalTime(purPlanEntity.getArrivalTime());
|
|
|
|
|
purOrderEntity.setInvCode(purPlanEntity.getInvCode());
|
|
|
|
|
purOrderEntity.setDeptCode(purPlanEntity.getDeptCode());
|
|
|
|
|
purOrderEntity.setCreateUser(purPlanEntity.getAuditUser());
|
|
|
|
|
purOrderEntity.setUpdateUser(purPlanEntity.getAuditUser());
|
|
|
|
|
if (basicBusTypeChangeEntity.getBusBeforeTime() != null) {
|
|
|
|
|
purPlanEntity.setCreateTime(DateUtil.timeProcess(purOrderEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
|
purPlanEntity.setUpdateTime(DateUtil.timeProcess(purOrderEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
|
}else{
|
|
|
|
|
purPlanEntity.setCreateTime(purOrderEntity.getCreateTime());
|
|
|
|
|
purPlanEntity.setUpdateUser(purOrderEntity.getAuditUser());
|
|
|
|
|
}
|
|
|
|
|
if (purOrderEntity.getStatus() == 3) {
|
|
|
|
|
purOrderEntity.setAuditUser("");
|
|
|
|
|
purOrderEntity.setAuditTime(new Date());
|
|
|
|
|
for (String key : purPlanDetailMap.keySet()) {
|
|
|
|
|
PurOrderEntity purOrderEntity = new PurOrderEntity();
|
|
|
|
|
List<PurPlanDetailEntity> purPlanDetailEntitys = purPlanDetailMap.get(key);
|
|
|
|
|
purOrderEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.CG_ORDER, "yyyyMMdd")));
|
|
|
|
|
purOrderEntity.setBillDate(purPlanEntity.getBillDate());
|
|
|
|
|
purOrderEntity.setSupId(key);
|
|
|
|
|
purOrderEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
|
|
|
|
|
purOrderEntity.setRemark(purPlanEntity.getRemark());
|
|
|
|
|
purOrderEntity.setEmergency(purPlanEntity.getEmergency());
|
|
|
|
|
purOrderEntity.setArrivalTime(purPlanEntity.getArrivalTime());
|
|
|
|
|
purOrderEntity.setInvCode(purPlanEntity.getInvCode());
|
|
|
|
|
purOrderEntity.setDeptCode(purPlanEntity.getDeptCode());
|
|
|
|
|
purOrderEntity.setCreateUser(purPlanEntity.getAuditUser());
|
|
|
|
|
purOrderEntity.setUpdateUser(purPlanEntity.getAuditUser());
|
|
|
|
|
if (basicBusTypeChangeEntity.getBusBeforeTime() != null) {
|
|
|
|
|
purOrderEntity.setCreateTime(DateUtil.timeProcess(new Date(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
|
purOrderEntity.setUpdateTime(DateUtil.timeProcess(new Date(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
|
} else {
|
|
|
|
|
purOrderEntity.setCreateTime(new Date());
|
|
|
|
|
purOrderEntity.setUpdateTime(new Date());
|
|
|
|
|
}
|
|
|
|
|
if (purOrderEntity.getStatus() == 3) {
|
|
|
|
|
purOrderEntity.setAuditUser("");
|
|
|
|
|
purOrderEntity.setAuditTime(new Date());
|
|
|
|
|
}
|
|
|
|
|
//插入订单主表
|
|
|
|
|
purOrderService.insert(purOrderEntity);
|
|
|
|
|
//用stream流复制list
|
|
|
|
|
List<PurOrderDetailEntity> purOrderDetailEntityList = purPlanDetailEntitys.stream().map(e -> {
|
|
|
|
|
PurOrderDetailEntity d = new PurOrderDetailEntity();
|
|
|
|
|
d.setOrderIdFk(purOrderEntity.getId() + "");
|
|
|
|
|
d.setProductId(e.getProductId());
|
|
|
|
|
d.setProductName(e.getProductName());
|
|
|
|
|
d.setCount(e.getCount());
|
|
|
|
|
d.setSupId(e.getSupId());
|
|
|
|
|
d.setZczbhhzbapzbh(e.getZczbhhzbapzbh());
|
|
|
|
|
return d;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
purOrderDetailService.insertPurOrderDetailEntity(purOrderDetailEntityList);
|
|
|
|
|
billNos = "," + billNos + purPlanEntity.getBillNo();
|
|
|
|
|
}
|
|
|
|
|
//插入订单主表
|
|
|
|
|
purOrderService.insert(purOrderEntity);
|
|
|
|
|
//用stream流复制list
|
|
|
|
|
List<PurOrderDetailEntity> purOrderDetailEntityList = purPlanDetailEntityList.stream().map(e -> {
|
|
|
|
|
PurOrderDetailEntity d = new PurOrderDetailEntity();
|
|
|
|
|
d.setOrderIdFk(purOrderEntity.getId() + "");
|
|
|
|
|
d.setProductId(e.getProductId());
|
|
|
|
|
d.setProductName(e.getProductName());
|
|
|
|
|
d.setCount(e.getCount());
|
|
|
|
|
d.setSupId(e.getSupId());
|
|
|
|
|
d.setZczbhhzbapzbh(e.getZczbhhzbapzbh());
|
|
|
|
|
return d;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
purOrderDetailService.insertPurOrderDetailEntity(purOrderDetailEntityList);
|
|
|
|
|
// 更新计划表信息插入订单单号
|
|
|
|
|
PurPlanEntity purPlanEntity1 = new PurPlanEntity();
|
|
|
|
|
purPlanEntity1.setId(purPlanEntity.getId());
|
|
|
|
|
purPlanEntity1.setStockOrderNo(purOrderEntity.getBillNo());
|
|
|
|
|
purPlanEntity1.setStockOrderNo(billNos.substring(0));
|
|
|
|
|
// purPlanEntity.sets(true);
|
|
|
|
|
purPlanService.update(purPlanEntity1);
|
|
|
|
|
}
|
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
|
purPlanGen(purPlanEntity);
|
|
|
|
|
}
|
|
|
|
|
// if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
|
// purPlanGen(purPlanEntity);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|