|
|
|
package com.glxp.api.controller.purchase;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
import com.glxp.api.constant.ConstantType;
|
|
|
|
import com.glxp.api.entity.basic.BasicBusTypeChangeEntity;
|
|
|
|
import com.glxp.api.entity.basic.BasicProductsEntity;
|
|
|
|
import com.glxp.api.entity.basic.UdiProductEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
import com.glxp.api.entity.inout.PurReceiveDetailEntity;
|
|
|
|
import com.glxp.api.entity.inout.PurReceiveEntity;
|
|
|
|
import com.glxp.api.entity.purchase.*;
|
|
|
|
import com.glxp.api.service.basic.IBasicBusTypeChangeService;
|
|
|
|
import com.glxp.api.service.basic.UdiProductService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderDetailBizService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
import com.glxp.api.service.inout.ReceiveService;
|
|
|
|
import com.glxp.api.service.inout.ReceivedetailService;
|
|
|
|
import com.glxp.api.service.purchase.*;
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
import com.glxp.api.util.DateUtil;
|
|
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Service
|
|
|
|
public class IoPurChangeService {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
IBasicBusTypeChangeService basicBusTypeChangeService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
ReceiveService receiveService;
|
|
|
|
@Resource
|
|
|
|
ReceivedetailService receivedetailService;
|
|
|
|
@Resource
|
|
|
|
PurApplyService purApplyService;
|
|
|
|
@Resource
|
|
|
|
PurApplyDetailService purApplyDetailService;
|
|
|
|
@Resource
|
|
|
|
PurPlanService purPlanService;
|
|
|
|
@Resource
|
|
|
|
PurPlanDetailService purPlanDetailService;
|
|
|
|
@Resource
|
|
|
|
PurOrderService purOrderService;
|
|
|
|
@Resource
|
|
|
|
PurOrderDetailService purOrderDetailService;
|
|
|
|
@Resource
|
|
|
|
GennerOrderUtils gennerOrderUtils;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
IoOrderService ioOrderService;
|
|
|
|
@Resource
|
|
|
|
IoOrderDetailBizService ioOrderDetailBizService;
|
|
|
|
|
|
|
|
//领用单流转
|
|
|
|
public void purReceiveChange(PurReceiveEntity purReceiveEntity) {
|
|
|
|
purReceiveEntity = receiveService.selectById(purReceiveEntity.getId());
|
|
|
|
List<PurReceiveDetailEntity> purReceiveDetailEntityList = receivedetailService.selectByOrderId(purReceiveEntity.getBillNo());
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(ConstantStatus.BUS_ORDER_HCLY);
|
|
|
|
|
|
|
|
//todo 领用单暂时不支持流转
|
|
|
|
// PurApplyEntity purApplyEntity = new PurApplyEntity();
|
|
|
|
// if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
// purApplyEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.SG_ORDER, "yyyyMMdd")));
|
|
|
|
// purApplyEntity.setBillDate(purReceiveEntity.getBillDate());
|
|
|
|
// purApplyEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
|
|
|
|
// purApplyEntity.setRemark(purReceiveEntity.getRemark());
|
|
|
|
// purApplyEntity.setInvCode(purReceiveEntity.getTargetInvCode());
|
|
|
|
// purApplyEntity.setDeptCode(purReceiveEntity.getTargetDeptCode());
|
|
|
|
// purApplyEntity.setTargetInvCode(purReceiveEntity.getInvCode());
|
|
|
|
// purApplyEntity.setTargetDeptCode(purReceiveEntity.getDeptCode());
|
|
|
|
// purApplyEntity.setCreateUser(purReceiveEntity.getAuditUser());
|
|
|
|
// purApplyEntity.setCreateTime(DateUtil.timeProcess(purReceiveEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
// purApplyEntity.setUpdateUser(purReceiveEntity.getAuditUser());
|
|
|
|
// purApplyEntity.setUpdateTime(DateUtil.timeProcess(purReceiveEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
// if (purApplyEntity.getStatus() == 3) {
|
|
|
|
// purApplyEntity.setAuditUser("");
|
|
|
|
// purApplyEntity.setAuditTime(new Date());
|
|
|
|
// }
|
|
|
|
// //插入申购主表
|
|
|
|
// purApplyService.insert(purApplyEntity);
|
|
|
|
// //用stream流复制list
|
|
|
|
// List<PurApplyDetailEntity> purApplyDetailEntityList = purReceiveDetailEntityList.stream().map(e -> {
|
|
|
|
// PurApplyDetailEntity d = new PurApplyDetailEntity();
|
|
|
|
// d.setOrderIdFk(purApplyEntity.getId() + "");
|
|
|
|
// d.setProductId(e.getRelIdFk().intValue());
|
|
|
|
// UdiProductEntity udiProductEntity = udiProductService.findByNameCode(e.getNameCode());
|
|
|
|
// d.setProductName(udiProductEntity.getCpmctymc());
|
|
|
|
// d.setCount(e.getCount());
|
|
|
|
// d.setSupId(e.getSupId());
|
|
|
|
// d.setZczbhhzbapzbh(udiProductEntity.getZczbhhzbapzbh());
|
|
|
|
// return d;
|
|
|
|
// })
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
// purApplyDetailService.insertPurApplyDetailEntity(purApplyDetailEntityList);
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
purReceiveGen(purReceiveEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//申购单流转
|
|
|
|
public void purApplyChange(PurApplyEntity purApplyEntity) {
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = new BasicBusTypeChangeEntity();
|
|
|
|
//查询申购详情
|
|
|
|
List<PurApplyDetailEntity> purApplyDetailEntityList = purApplyDetailService.findByOrderId(purApplyEntity.getId() + "");
|
|
|
|
System.out.println("//---------------------------------判断申购为已审核就生成计划单-------------------------------------------//");
|
|
|
|
//---------------------------------判断申购为已审核就生成计划单-------------------------------------------//
|
|
|
|
PurPlanEntity purPlanEntity = new PurPlanEntity();
|
|
|
|
List<PurPlanDetailEntity> purPlanDetailEntityList = new ArrayList<>();
|
|
|
|
if (purApplyEntity.getStatus() == 3) {
|
|
|
|
basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction("CPSG");
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
purPlanEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.JH_ORDER, "yyyyMMdd")));
|
|
|
|
purPlanEntity.setBillDate(purApplyEntity.getBillDate());
|
|
|
|
purPlanEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
|
|
|
|
purPlanEntity.setRemark(purApplyEntity.getRemark());
|
|
|
|
purPlanEntity.setEmergency(purApplyEntity.getEmergency());
|
|
|
|
purPlanEntity.setArrivalTime(purApplyEntity.getArrivalTime());
|
|
|
|
purPlanEntity.setInvCode(purApplyEntity.getInvCode());
|
|
|
|
purPlanEntity.setDeptCode(purApplyEntity.getDeptCode());
|
|
|
|
purPlanEntity.setCreateUser(purApplyEntity.getAuditUser());
|
|
|
|
if (basicBusTypeChangeEntity.getBusBeforeTime() != null) {
|
|
|
|
purPlanEntity.setCreateTime(DateUtil.timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
purPlanEntity.setUpdateTime(DateUtil.timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
|
|
} else {
|
|
|
|
purPlanEntity.setCreateTime(purApplyEntity.getCreateTime());
|
|
|
|
purPlanEntity.setUpdateUser(purApplyEntity.getAuditUser());
|
|
|
|
}
|
|
|
|
purPlanEntity.setUpdateTime(purApplyEntity.getUpdateTime());
|
|
|
|
if (purPlanEntity.getStatus() == 3) {
|
|
|
|
purPlanEntity.setAuditUser("");
|
|
|
|
purPlanEntity.setAuditTime(new Date());
|
|
|
|
}
|
|
|
|
//插入计划主表
|
|
|
|
purPlanService.insert(purPlanEntity);
|
|
|
|
//用stream流复制list
|
|
|
|
purPlanDetailEntityList = purApplyDetailEntityList.stream().map(e -> {
|
|
|
|
PurPlanDetailEntity d = new PurPlanDetailEntity();
|
|
|
|
d.setOrderIdFk(purPlanEntity.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());
|
|
|
|
purPlanDetailService.insertPurPlanDetailEntity(purPlanDetailEntityList);
|
|
|
|
purPlanChange(purPlanEntity);
|
|
|
|
//更新申购表信息插入计划单号
|
|
|
|
PurApplyEntity purApplyEntity1 = new PurApplyEntity();
|
|
|
|
purApplyEntity1.setId(purApplyEntity.getId());
|
|
|
|
purApplyEntity1.setPlanBillNo(purPlanEntity.getBillNo());
|
|
|
|
purApplyEntity1.setGeneratePlan(true);
|
|
|
|
purApplyService.update(purApplyEntity1);
|
|
|
|
}
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
purApplyGen(purApplyEntity);
|
|
|
|
System.out.println("6666666666666666666999999999999999");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//采购计划流转
|
|
|
|
public void purPlanChange(PurPlanEntity purPlanEntity) {
|
|
|
|
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity;
|
|
|
|
String billNos = null;
|
|
|
|
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
|
|
|
|
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) {
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
// 更新计划表信息插入订单单号
|
|
|
|
PurPlanEntity purPlanEntity1 = new PurPlanEntity();
|
|
|
|
purPlanEntity1.setId(purPlanEntity.getId());
|
|
|
|
purPlanEntity1.setStockOrderNo(billNos.substring(0));
|
|
|
|
// purPlanEntity.sets(true);
|
|
|
|
purPlanService.update(purPlanEntity1);
|
|
|
|
}
|
|
|
|
// if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
// purPlanGen(purPlanEntity);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//采购订单流转
|
|
|
|
public void purOrderChange(PurOrderEntity purOrderEntity) {
|
|
|
|
//最后一层,无法流转业务单
|
|
|
|
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(ConstantStatus.BUS_ORDER_CGDD);
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
purOrderGen(purOrderEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//领用单生成扫码单据
|
|
|
|
public void purReceiveGen(PurReceiveEntity purReceiveEntity) {
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(ConstantStatus.BUS_ORDER_HCLY);
|
|
|
|
purReceiveEntity = receiveService.selectById(purReceiveEntity.getId());
|
|
|
|
List<PurReceiveDetailEntity> purReceiveDetailEntityList = receivedetailService.selectByOrderId(purReceiveEntity.getBillNo());
|
|
|
|
Map<String, List<PurReceiveDetailEntity>> map = purReceiveDetailEntityList.stream().collect(Collectors.groupingBy(PurReceiveDetailEntity::getSupId));
|
|
|
|
String billNo = "";
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
for (Map.Entry<String, List<PurReceiveDetailEntity>> m : map.entrySet()) {
|
|
|
|
//生产单据表信息
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
ioOrderEntity.setBillNo(gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")));
|
|
|
|
ioOrderEntity.setCorpOrderId(CustomUtil.getDate());
|
|
|
|
ioOrderEntity.setMainAction(ConstantType.TYPE_PUT);
|
|
|
|
ioOrderEntity.setAction(basicBusTypeChangeEntity.getTargetAction());
|
|
|
|
ioOrderEntity.setFromCorp(m.getKey());
|
|
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_PLAN);
|
|
|
|
ioOrderEntity.setStatus(1);
|
|
|
|
ioOrderEntity.setDealStatus(1);
|
|
|
|
ioOrderEntity.setOrderType(1);
|
|
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
|
|
ioOrderEntity.setCreateUser(purReceiveEntity.getCreateUser());
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
ioOrderEntity.setUpdateUser(purReceiveEntity.getCreateUser());
|
|
|
|
ioOrderEntity.setCustomerId("110");
|
|
|
|
ioOrderEntity.setDeptCode(purReceiveEntity.getInvCode());
|
|
|
|
ioOrderEntity.setInvCode(purReceiveEntity.getDeptCode());
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
billNo += ioOrderEntity.getBillNo() + ",";
|
|
|
|
//插入业务单表
|
|
|
|
for (PurReceiveDetailEntity obj : m.getValue()) {
|
|
|
|
BasicProductsEntity basicProductsEntity = receivedetailService.selectIoOrderDetailBiz(obj.getId());
|
|
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
ioOrderDetailBizEntity.setOrderIdFk(ioOrderEntity.getBillNo());
|
|
|
|
ioOrderDetailBizEntity.setBindRlFk(obj.getRelIdFk());
|
|
|
|
ioOrderDetailBizEntity.setCount(obj.getCount());
|
|
|
|
ioOrderDetailBizEntity.setUuidFk(basicProductsEntity.getUuid());
|
|
|
|
ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode());
|
|
|
|
ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc());
|
|
|
|
ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh());
|
|
|
|
ioOrderDetailBizEntity.setYlqxzcrbarmc(basicProductsEntity.getYlqxzcrbarmc());
|
|
|
|
ioOrderDetailBizEntity.setManufacturer(basicProductsEntity.getManufactory());
|
|
|
|
ioOrderDetailBizEntity.setMeasname(basicProductsEntity.getMeasname());
|
|
|
|
ioOrderDetailBizEntity.setSpec(basicProductsEntity.getGgxh());
|
|
|
|
if (basicProductsEntity.getPrice() != null) {
|
|
|
|
ioOrderDetailBizEntity.setPrice(BigDecimal.valueOf(basicProductsEntity.getPrice()));
|
|
|
|
}
|
|
|
|
ioOrderDetailBizEntity.setSupId(obj.getSupId());
|
|
|
|
ioOrderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// purReceiveEntity.se(billNo.substring(0, billNo.length() - 1));
|
|
|
|
// receiveService.update(purPlanEntity1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//申购单生成扫码单据
|
|
|
|
public void purApplyGen(PurApplyEntity purApplyEntity) {
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(ConstantStatus.BUS_ORDER_HCLY);
|
|
|
|
List<PurApplyDetailEntity> purApplyDetailEntityList = purApplyDetailService.findByOrderId(purApplyEntity.getId() + "");
|
|
|
|
Map<String, List<PurApplyDetailEntity>> map = purApplyDetailEntityList.stream().collect(Collectors.groupingBy(PurApplyDetailEntity::getSupId));
|
|
|
|
String billNo = "";
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
for (Map.Entry<String, List<PurApplyDetailEntity>> m : map.entrySet()) {
|
|
|
|
//生产单据表信息
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
ioOrderEntity.setBillNo(gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")));
|
|
|
|
ioOrderEntity.setCorpOrderId(CustomUtil.getDate());
|
|
|
|
ioOrderEntity.setMainAction(ConstantType.TYPE_PUT);
|
|
|
|
ioOrderEntity.setAction(basicBusTypeChangeEntity.getTargetAction());
|
|
|
|
ioOrderEntity.setFromCorp(m.getKey());
|
|
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_PLAN);
|
|
|
|
ioOrderEntity.setStatus(1);
|
|
|
|
ioOrderEntity.setDealStatus(1);
|
|
|
|
ioOrderEntity.setOrderType(1);
|
|
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
|
|
ioOrderEntity.setCreateUser(purApplyEntity.getCreateUser());
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
ioOrderEntity.setUpdateUser(purApplyEntity.getCreateUser());
|
|
|
|
ioOrderEntity.setCustomerId("110");
|
|
|
|
ioOrderEntity.setDeptCode(purApplyEntity.getInvCode());
|
|
|
|
ioOrderEntity.setInvCode(purApplyEntity.getDeptCode());
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
billNo += ioOrderEntity.getBillNo() + ",";
|
|
|
|
//插入业务单表
|
|
|
|
for (PurApplyDetailEntity obj : m.getValue()) {
|
|
|
|
BasicProductsEntity basicProductsEntity = purPlanDetailService.selectIoOrderDetailBiz(obj.getId());
|
|
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
ioOrderDetailBizEntity.setOrderIdFk(ioOrderEntity.getBillNo());
|
|
|
|
ioOrderDetailBizEntity.setBindRlFk(Long.valueOf(obj.getProductId()));
|
|
|
|
ioOrderDetailBizEntity.setCount(obj.getCount());
|
|
|
|
if (basicProductsEntity != null && basicProductsEntity.getUuid() != null) {
|
|
|
|
ioOrderDetailBizEntity.setUuidFk(basicProductsEntity.getUuid());
|
|
|
|
}
|
|
|
|
// ioOrderDetailBizEntity.setUuidFk(basicProductsEntity.getUuid());
|
|
|
|
// ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode());
|
|
|
|
if (basicProductsEntity != null && basicProductsEntity.getNameCode() != null) {
|
|
|
|
ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode());
|
|
|
|
}
|
|
|
|
if (basicProductsEntity != null && basicProductsEntity.getCpmctymc() != null) {
|
|
|
|
ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (basicProductsEntity != null && basicProductsEntity.getZczbhhzbapzbh() != null) {
|
|
|
|
ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh());
|
|
|
|
}
|
|
|
|
if (basicProductsEntity != null && basicProductsEntity.getYlqxzcrbarmc() != null) {
|
|
|
|
ioOrderDetailBizEntity.setYlqxzcrbarmc(basicProductsEntity.getYlqxzcrbarmc());
|
|
|
|
}
|
|
|
|
if (basicProductsEntity != null && basicProductsEntity.getManufactory() != null) {
|
|
|
|
ioOrderDetailBizEntity.setManufacturer(basicProductsEntity.getManufactory());
|
|
|
|
}
|
|
|
|
if (basicProductsEntity != null && basicProductsEntity.getMeasname() != null) {
|
|
|
|
ioOrderDetailBizEntity.setMeasname(basicProductsEntity.getMeasname());
|
|
|
|
}
|
|
|
|
if (basicProductsEntity != null && basicProductsEntity.getGgxh() != null) {
|
|
|
|
ioOrderDetailBizEntity.setSpec(basicProductsEntity.getGgxh());
|
|
|
|
}
|
|
|
|
// if (basicProductsEntity.getPrice() != null) {
|
|
|
|
// ioOrderDetailBizEntity.setPrice(BigDecimal.valueOf(basicProductsEntity.getPrice()));
|
|
|
|
// }
|
|
|
|
if (basicProductsEntity.getPrice() != null && basicProductsEntity.getPrice() != null) {
|
|
|
|
ioOrderDetailBizEntity.setPrice(BigDecimal.valueOf(basicProductsEntity.getPrice()));
|
|
|
|
}
|
|
|
|
ioOrderDetailBizEntity.setSupId(obj.getSupId());
|
|
|
|
ioOrderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// PurPlanEntity purPlanEntity1 = new PurPlanEntity();
|
|
|
|
// purPlanEntity1.setId(purPlanEntity.getId());
|
|
|
|
// purPlanEntity1.setStockOrderNo(billNo.substring(0, billNo.length() - 1));
|
|
|
|
// purPlanService.update(purPlanEntity1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//采购计划生成扫码单据
|
|
|
|
public void purPlanGen(PurPlanEntity purPlanEntity) {
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = new BasicBusTypeChangeEntity();
|
|
|
|
basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction("CGJH");
|
|
|
|
List<PurPlanDetailEntity> purPlanDetailEntities = purPlanDetailService.findByOrderId(purPlanEntity.getId() + "");
|
|
|
|
//对计划单里面的供应商进行分组
|
|
|
|
Map<String, List<PurPlanDetailEntity>> map = purPlanDetailEntities.stream().collect(Collectors.groupingBy(PurPlanDetailEntity::getSupId));
|
|
|
|
String billNo = "";
|
|
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
|
|
for (Map.Entry<String, List<PurPlanDetailEntity>> m : map.entrySet()) {
|
|
|
|
//生产单据表信息
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
ioOrderEntity.setBillNo(gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")));
|
|
|
|
ioOrderEntity.setCorpOrderId(CustomUtil.getDate());
|
|
|
|
ioOrderEntity.setMainAction(ConstantType.TYPE_PUT);
|
|
|
|
ioOrderEntity.setAction(basicBusTypeChangeEntity.getTargetAction());
|
|
|
|
ioOrderEntity.setFromCorp(m.getKey());
|
|
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_PLAN);
|
|
|
|
ioOrderEntity.setStatus(1);
|
|
|
|
ioOrderEntity.setDealStatus(1);
|
|
|
|
ioOrderEntity.setOrderType(1);
|
|
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
|
|
ioOrderEntity.setCreateUser(purPlanEntity.getCreateUser());
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
ioOrderEntity.setUpdateUser(purPlanEntity.getCreateUser());
|
|
|
|
ioOrderEntity.setCustomerId("110");
|
|
|
|
ioOrderEntity.setDeptCode(purPlanEntity.getDeptCode());
|
|
|
|
ioOrderEntity.setInvCode(purPlanEntity.getInvCode());
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
billNo += ioOrderEntity.getBillNo() + ",";
|
|
|
|
//插入业务单表
|
|
|
|
for (PurPlanDetailEntity obj : m.getValue()) {
|
|
|
|
BasicProductsEntity basicProductsEntity = purPlanDetailService.selectIoOrderDetailBiz(obj.getId());
|
|
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
ioOrderDetailBizEntity.setOrderIdFk(ioOrderEntity.getBillNo());
|
|
|
|
ioOrderDetailBizEntity.setBindRlFk(Long.valueOf(obj.getProductId()));
|
|
|
|
ioOrderDetailBizEntity.setCount(obj.getCount());
|
|
|
|
ioOrderDetailBizEntity.setUuidFk(basicProductsEntity.getUuid());
|
|
|
|
ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode());
|
|
|
|
ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc());
|
|
|
|
ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh());
|
|
|
|
ioOrderDetailBizEntity.setYlqxzcrbarmc(basicProductsEntity.getYlqxzcrbarmc());
|
|
|
|
ioOrderDetailBizEntity.setManufacturer(basicProductsEntity.getManufactory());
|
|
|
|
ioOrderDetailBizEntity.setMeasname(basicProductsEntity.getMeasname());
|
|
|
|
ioOrderDetailBizEntity.setSpec(basicProductsEntity.getGgxh());
|
|
|
|
if (basicProductsEntity.getPrice() != null) {
|
|
|
|
ioOrderDetailBizEntity.setPrice(BigDecimal.valueOf(basicProductsEntity.getPrice()));
|
|
|
|
}
|
|
|
|
ioOrderDetailBizEntity.setSupId(obj.getSupId());
|
|
|
|
ioOrderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
purPlanEntity.setId(purPlanEntity.getId());
|
|
|
|
purPlanEntity.setStockOrderNo(billNo.substring(0, billNo.length() - 1));
|
|
|
|
purPlanService.update(purPlanEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//采购订单生成扫码单据
|
|
|
|
public void purOrderGen(PurOrderEntity purOrderEntity) {
|
|
|
|
List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailService.findByOrderId(purOrderEntity.getId() + "");
|
|
|
|
|
|
|
|
//对计划单里面的供应商进行分组
|
|
|
|
Map<String, List<PurOrderDetailEntity>> map = purOrderDetailEntities.stream().collect(Collectors.groupingBy(PurOrderDetailEntity::getSupId));
|
|
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(ConstantStatus.BUS_ORDER_CGDD);
|
|
|
|
String billNo = "";
|
|
|
|
if (purOrderEntity.getStatus() == ConstantStatus.APPLY_AUDIT_ED) {
|
|
|
|
for (Map.Entry<String, List<PurOrderDetailEntity>> m : map.entrySet()) {
|
|
|
|
//生产单据表信息
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
ioOrderEntity.setBillNo(gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")));
|
|
|
|
ioOrderEntity.setCorpOrderId(CustomUtil.getDate());
|
|
|
|
ioOrderEntity.setMainAction(ConstantType.TYPE_PUT);
|
|
|
|
ioOrderEntity.setAction(basicBusTypeChangeEntity.getTargetAction());
|
|
|
|
ioOrderEntity.setFromCorp(m.getKey());
|
|
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_Order);
|
|
|
|
if (basicBusTypeChangeEntity.getAuditStatus() == 1) {
|
|
|
|
ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
|
|
|
|
ioOrderEntity.setDealStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
|
|
|
|
} else if (basicBusTypeChangeEntity.getAuditStatus() == 2) {
|
|
|
|
ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
ioOrderEntity.setDealStatus(ConstantStatus.ORDER_STATUS_PROCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
ioOrderEntity.setOrderType(1);
|
|
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
|
|
// ioOrderEntity.setCreateUser(postPurOrderRequest.getPurOrderEntity().getAuditUser());
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
// ioOrderEntity.setUpdateUser(postPurOrderRequest.getPurOrderEntity().getAuditUser());
|
|
|
|
ioOrderEntity.setCustomerId("110");
|
|
|
|
ioOrderEntity.setDeptCode(purOrderEntity.getDeptCode());
|
|
|
|
ioOrderEntity.setInvCode(purOrderEntity.getInvCode());
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
billNo += ioOrderEntity.getBillNo() + ",";
|
|
|
|
//插入业务单表
|
|
|
|
for (PurOrderDetailEntity obj : m.getValue()) {
|
|
|
|
BasicProductsEntity basicProductsEntity = purOrderDetailService.selectIoOrderDetailBiz(obj.getId());
|
|
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
ioOrderDetailBizEntity.setOrderIdFk(ioOrderEntity.getBillNo());
|
|
|
|
ioOrderDetailBizEntity.setBindRlFk(Long.valueOf(obj.getProductId()));
|
|
|
|
ioOrderDetailBizEntity.setCount(obj.getCount());
|
|
|
|
ioOrderDetailBizEntity.setUuidFk(basicProductsEntity.getUuid());
|
|
|
|
ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode());
|
|
|
|
ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc());
|
|
|
|
ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh());
|
|
|
|
ioOrderDetailBizEntity.setYlqxzcrbarmc(basicProductsEntity.getYlqxzcrbarmc());
|
|
|
|
ioOrderDetailBizEntity.setManufacturer(basicProductsEntity.getManufactory());
|
|
|
|
ioOrderDetailBizEntity.setMeasname(basicProductsEntity.getMeasname());
|
|
|
|
ioOrderDetailBizEntity.setSpec(basicProductsEntity.getGgxh());
|
|
|
|
if (basicProductsEntity.getPrice() != null) {
|
|
|
|
ioOrderDetailBizEntity.setPrice(BigDecimal.valueOf(basicProductsEntity.getPrice()));
|
|
|
|
}
|
|
|
|
ioOrderDetailBizEntity.setSupId(obj.getSupId());
|
|
|
|
ioOrderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
purOrderEntity.setStockOrderNo(billNo.substring(0, billNo.length() - 1));
|
|
|
|
purOrderService.update(purOrderEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|