业务单据流转相关修改

master
anthonywj 2 years ago
parent b2779284f0
commit ff9fd56cc0

@ -59,8 +59,6 @@ public class IoPurChangeService {
PurOrderDetailService purOrderDetailService;
@Resource
GennerOrderUtils gennerOrderUtils;
@Resource
UdiProductService udiProductService;
@Resource
IoOrderService ioOrderService;
@ -72,42 +70,49 @@ public class IoPurChangeService {
purReceiveEntity = receiveService.selectById(purReceiveEntity.getId());
List<PurReceiveDetailEntity> purReceiveDetailEntityList = receivedetailService.selectByOrderId(purReceiveEntity.getBillNo());
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(ConstantStatus.BUS_ORDER_HCLY);
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);
//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);
}
}
//申购单流转
@ -151,6 +156,10 @@ public class IoPurChangeService {
return d;
}).collect(Collectors.toList());
purPlanDetailService.insertPurPlanDetailEntity(purPlanDetailEntityList);
purPlanChange(purPlanEntity);
//更新申购表信息插入计划单号
PurApplyEntity purApplyEntity1 = new PurApplyEntity();
purApplyEntity1.setId(purApplyEntity.getId());
@ -158,6 +167,11 @@ public class IoPurChangeService {
purApplyEntity1.setGeneratePlan(true);
purApplyService.update(purApplyEntity1);
}
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
purApplyGen(purApplyEntity);
}
}
}
@ -165,12 +179,13 @@ public class IoPurChangeService {
//采购计划流转
public void purPlanChange(PurPlanEntity purPlanEntity) {
BasicBusTypeChangeEntity basicBusTypeChangeEntity = new BasicBusTypeChangeEntity();
//查询计划详情
List<PurPlanDetailEntity> purPlanDetailEntityList = purPlanDetailService.findByOrderId(purPlanEntity.getId() + "");
BasicBusTypeChangeEntity basicBusTypeChangeEntity;
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
PurOrderEntity purOrderEntity = new PurOrderEntity();
if (purPlanEntity.getStatus() == 3) {
//查询计划详情
List<PurPlanDetailEntity> purPlanDetailEntityList = purPlanDetailService.findByOrderId(purPlanEntity.getId() + "");
basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction("CGJH");
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
purOrderEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.CG_ORDER, "yyyyMMdd")));
@ -210,6 +225,9 @@ public class IoPurChangeService {
// purPlanEntity.sets(true);
purPlanService.update(purPlanEntity1);
}
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
purPlanGen(purPlanEntity);
}
}
}
@ -219,6 +237,10 @@ public class IoPurChangeService {
public void purOrderChange(PurOrderEntity purOrderEntity) {
//最后一层,无法流转业务单
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(ConstantStatus.BUS_ORDER_CGDD);
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
purOrderGen(purOrderEntity);
}
}

@ -63,8 +63,6 @@ public class PurApplyController {
@Resource
PurPlanDetailService purPlanDetailService;
@Resource
UdiProductService udiProductService;
@Resource
IBasicBusTypeChangeService basicBusTypeChangeService;
@Resource
@ -79,6 +77,9 @@ public class PurApplyController {
IoOrderService ioOrderService;
@Resource
IoOrderDetailBizService ioOrderDetailBizService;
@Resource
IoPurChangeService purChangeService;
/**
*
*/
@ -93,7 +94,7 @@ public class PurApplyController {
purApplyEntity.setCreateTime(new Date());
purApplyEntity.setUpdateTime(new Date());
purApplyEntity.setStatus(postPurApplyRequest.getEditStatus()); //草稿状态
if(postPurApplyRequest.getType()!=null){
if (postPurApplyRequest.getType() != null) {
String billNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.SG_ORDER, "yyyyMMdd"));
purApplyEntity.setBillNo(billNo);
}
@ -165,8 +166,9 @@ public class PurApplyController {
purApplyEntity.setAuditUser(userId + "");
purApplyService.update(purApplyEntity);
if(purApplyRequest.getStatus()==3){
generateDocument(purApplyEntity);
if (purApplyRequest.getStatus() == 3) {
// generateDocument(purApplyEntity);
purChangeService.purApplyChange(purApplyEntity);
}
@ -208,164 +210,163 @@ public class PurApplyController {
}
//根据单据生成新单据
public Boolean generateDocument(PurApplyEntity purApplyEntity){
BasicBusTypeChangeEntity basicBusTypeChangeEntity=new BasicBusTypeChangeEntity();
//查询申购详情
List<PurApplyDetailEntity> purApplyDetailEntityList=purApplyDetailService.findByOrderId(purApplyEntity.getId()+"");
//---------------------------------判断申购为已审核就生成计划单-------------------------------------------//
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());
purPlanEntity.setCreateTime(timeProcess(purApplyEntity.getCreateTime(),basicBusTypeChangeEntity.getBusBeforeTime()));
purPlanEntity.setUpdateUser(purApplyEntity.getAuditUser());
purPlanEntity.setUpdateTime(timeProcess(purApplyEntity.getCreateTime(),basicBusTypeChangeEntity.getBusBeforeTime()));
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);
//更新申购表信息插入计划单号
PurApplyEntity purApplyEntity1=new PurApplyEntity();
purApplyEntity1.setId(purApplyEntity.getId());
purApplyEntity1.setPlanBillNo(purPlanEntity.getBillNo());
purApplyEntity1.setGeneratePlan(true);
purApplyService.update(purApplyEntity1);
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
PurOrderEntity purOrderEntity=new PurOrderEntity();
if(purPlanEntity.getStatus()==3){
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(purApplyEntity.getBillDate());
purOrderEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
purOrderEntity.setRemark(purApplyEntity.getRemark());
purOrderEntity.setEmergency(purApplyEntity.getEmergency());
purOrderEntity.setArrivalTime(purApplyEntity.getArrivalTime());
purOrderEntity.setInvCode(purApplyEntity.getInvCode());
purOrderEntity.setDeptCode(purApplyEntity.getDeptCode());
purOrderEntity.setCreateUser(purApplyEntity.getAuditUser());
purOrderEntity.setCreateTime(timeProcess(purApplyEntity.getCreateTime(),basicBusTypeChangeEntity.getBusBeforeTime()));
purOrderEntity.setUpdateUser(purApplyEntity.getAuditUser());
purOrderEntity.setUpdateTime(timeProcess(purApplyEntity.getCreateTime(),basicBusTypeChangeEntity.getBusBeforeTime()));
if(purOrderEntity.getStatus()==3){
purOrderEntity.setAuditUser("");
purOrderEntity.setAuditTime(new Date());
}
//插入订单主表
purOrderService.insert(purOrderEntity);
//用stream流复制list
List<PurOrderDetailEntity> purOrderDetailEntityList = purApplyDetailEntityList.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());
// purPlanEntity.sets(true);
purPlanService.update(purPlanEntity1);
public Boolean generateDocument(PurApplyEntity purApplyEntity) {
BasicBusTypeChangeEntity basicBusTypeChangeEntity = new BasicBusTypeChangeEntity();
//查询申购详情
List<PurApplyDetailEntity> purApplyDetailEntityList = purApplyDetailService.findByOrderId(purApplyEntity.getId() + "");
//---------------------------------判断申购为已审核就生成计划单-------------------------------------------//
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());
purPlanEntity.setCreateTime(timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
purPlanEntity.setUpdateUser(purApplyEntity.getAuditUser());
purPlanEntity.setUpdateTime(timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
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);
//更新申购表信息插入计划单号
PurApplyEntity purApplyEntity1 = new PurApplyEntity();
purApplyEntity1.setId(purApplyEntity.getId());
purApplyEntity1.setPlanBillNo(purPlanEntity.getBillNo());
purApplyEntity1.setGeneratePlan(true);
purApplyService.update(purApplyEntity1);
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
PurOrderEntity purOrderEntity = new PurOrderEntity();
if (purPlanEntity.getStatus() == 3) {
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(purApplyEntity.getBillDate());
purOrderEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
purOrderEntity.setRemark(purApplyEntity.getRemark());
purOrderEntity.setEmergency(purApplyEntity.getEmergency());
purOrderEntity.setArrivalTime(purApplyEntity.getArrivalTime());
purOrderEntity.setInvCode(purApplyEntity.getInvCode());
purOrderEntity.setDeptCode(purApplyEntity.getDeptCode());
purOrderEntity.setCreateUser(purApplyEntity.getAuditUser());
purOrderEntity.setCreateTime(timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
purOrderEntity.setUpdateUser(purApplyEntity.getAuditUser());
purOrderEntity.setUpdateTime(timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
if (purOrderEntity.getStatus() == 3) {
purOrderEntity.setAuditUser("");
purOrderEntity.setAuditTime(new Date());
}
//---------------------------------判断计划为已审核就生成采购入库单-------------------------------------------//\
//查询申购单详情
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(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 (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);
//插入订单主表
purOrderService.insert(purOrderEntity);
//用stream流复制list
List<PurOrderDetailEntity> purOrderDetailEntityList = purApplyDetailEntityList.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());
// purPlanEntity.sets(true);
purPlanService.update(purPlanEntity1);
}
//---------------------------------判断计划为已审核就生成采购入库单-------------------------------------------//\
//查询申购单详情
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(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 (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 purPlanEntity1=new PurPlanEntity();
purPlanEntity1.setId(purPlanEntity.getId());
purPlanEntity1.setStockOrderNo(billNo.substring(0,billNo.length()-1));
purPlanService.update(purPlanEntity1);
}
PurPlanEntity purPlanEntity1 = new PurPlanEntity();
purPlanEntity1.setId(purPlanEntity.getId());
purPlanEntity1.setStockOrderNo(billNo.substring(0, billNo.length() - 1));
purPlanService.update(purPlanEntity1);
}
}
}
}
return true;
}
public Date timeProcess(Date date,Integer timeCount) {
public Date timeProcess(Date date, Integer timeCount) {
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(date);
rightNow.add(Calendar.HOUR,timeCount);
rightNow.add(Calendar.HOUR, timeCount);
Date dt1 = rightNow.getTime();
return dt1;
}
@ -462,7 +463,7 @@ public class PurApplyController {
return ResultVOUtils.success("删除成功");
}
/*** 插入申购单详情 */
/*** 插入申购单详情 */
/**
*
*/
@ -473,6 +474,7 @@ public class PurApplyController {
purApplyDetailService.insert(purApplyDetailEntity);
return ResultVOUtils.success(purApplyDetailEntity.getOrderIdFk());
}
/**
*
*/
@ -487,7 +489,7 @@ public class PurApplyController {
purApplyEntity.setUpdateTime(new Date());
purApplyEntity.setUpdateUser(userId + "");
purApplyService.insert(purApplyEntity);
Long id=purApplyEntity.getId();
Long id = purApplyEntity.getId();
return ResultVOUtils.success(id);
}
@ -499,13 +501,13 @@ public class PurApplyController {
@PostMapping("/purchase/apply/delApplyDetailAll")
public BaseResponse delApplyDetailAll(@RequestBody PurApplyEntity purApplyEntity) {
if(purApplyEntity.getId()!=null){
purApplyService.deleteById(purApplyEntity.getId());
purApplyDetailService.deleteByOrderId(purApplyEntity.getId() + "" );
}else {
return ResultVOUtils.error(999,"参数有误!");
if (purApplyEntity.getId() != null) {
purApplyService.deleteById(purApplyEntity.getId());
purApplyDetailService.deleteByOrderId(purApplyEntity.getId() + "");
} else {
return ResultVOUtils.error(999, "参数有误!");
}
return ResultVOUtils.success();
return ResultVOUtils.success();
}

@ -66,7 +66,8 @@ public class PurOrderController {
IoOrderService ioOrderService;
@Resource
IoOrderDetailBizService ioOrderDetailBizService;
@Resource
IoPurChangeService purChangeService;
/**
*
@ -85,7 +86,7 @@ public class PurOrderController {
purOrderEntity.setUpdateUser(userId + "");
purOrderEntity.setStatus(postPurOrderRequest.getEditStatus()); //草稿状态
if(postPurOrderRequest.getType()!=null){
if (postPurOrderRequest.getType() != null) {
String billNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.SG_ORDER, "yyyyMMdd"));
purOrderEntity.setBillNo(billNo);
}
@ -150,69 +151,73 @@ public class PurOrderController {
Long userId = customerService.getUserId();
PurOrderEntity purOrderEntity = postPurOrderRequest.getPurOrderEntity();
purOrderEntity.setUpdateTime(new Date());
purOrderEntity.setUpdateUser(userId+"");
purOrderEntity.setUpdateUser(userId + "");
purOrderEntity.setAuditUser(userId + "");
purOrderEntity.setAuditTime(new Date());
purOrderEntity.setStatus(postPurOrderRequest.getEditStatus());
purOrderService.update(purOrderEntity);
String billNo="";
List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailService.findByOrderId(purOrderEntity.getId() + "");
//对计划单里面的供应商进行分组
Map<String, List<PurOrderDetailEntity>> map = purOrderDetailEntities.stream().collect(Collectors.groupingBy(PurOrderDetailEntity::getSupId));
if (postPurOrderRequest.getEditStatus() == ConstantStatus.APPLY_AUDIT_ED) {
if (CollUtil.isNotEmpty(purOrderDetailEntities) && postPurOrderRequest.isAutoPurchase()==true
&& StrUtil.isNotEmpty(postPurOrderRequest.getTargetSubInv()) && StrUtil.isNotEmpty(postPurOrderRequest.getTargetBillAction()) ) {
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(postPurOrderRequest.getTargetBillAction());
ioOrderEntity.setFromCorp(m.getKey());
ioOrderEntity.setFromType(ConstantStatus.FROM_Order);
ioOrderEntity.setStatus(1);
ioOrderEntity.setDealStatus(1);
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(postPurOrderRequest.getTargetDeptCode());
ioOrderEntity.setInvCode(postPurOrderRequest.getTargetSubInv());
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);
}
}
purChangeService.purOrderChange(purOrderEntity);
// String billNo = "";
// List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailService.findByOrderId(purOrderEntity.getId() + "");
//
// //对计划单里面的供应商进行分组
// Map<String, List<PurOrderDetailEntity>> map = purOrderDetailEntities.stream().collect(Collectors.groupingBy(PurOrderDetailEntity::getSupId));
//
// if (postPurOrderRequest.getEditStatus() == ConstantStatus.APPLY_AUDIT_ED) {
//
// if (CollUtil.isNotEmpty(purOrderDetailEntities) && postPurOrderRequest.isAutoPurchase() == true
// && StrUtil.isNotEmpty(postPurOrderRequest.getTargetSubInv()) && StrUtil.isNotEmpty(postPurOrderRequest.getTargetBillAction())) {
//
// 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(postPurOrderRequest.getTargetBillAction());
// ioOrderEntity.setFromCorp(m.getKey());
// ioOrderEntity.setFromType(ConstantStatus.FROM_Order);
// ioOrderEntity.setStatus(1);
// ioOrderEntity.setDealStatus(1);
// 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(postPurOrderRequest.getTargetDeptCode());
// ioOrderEntity.setInvCode(postPurOrderRequest.getTargetSubInv());
// 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);
// }
// }
return ResultVOUtils.success("更新成功!");
}
@ -237,55 +242,55 @@ public class PurOrderController {
*
*/
@PostMapping("/purchase/order/addPlanDetailAndOrder")
public BaseResponse addPlanDetailAndOrder(@RequestBody PurOrderRequest purOrderRequest) {
public BaseResponse addPlanDetailAndOrder(@RequestBody PurOrderRequest purOrderRequest) {
if (purOrderRequest.getApplyId() == null || purOrderRequest.getId() == null) {
return ResultVOUtils.error(999,"参数错误!");
return ResultVOUtils.error(999, "参数错误!");
}
//查询申购单详情
PurPlanDetailRequest purPlanDetailRequest=new PurPlanDetailRequest();
purPlanDetailRequest.setOrderIdFk(purOrderRequest.getApplyId()+"");
List<PurPlanDetailEntity> purApplyDetailEntityList=purPlanDetailService.getPurPlanDetailEntityList(purPlanDetailRequest);
PurPlanDetailRequest purPlanDetailRequest = new PurPlanDetailRequest();
purPlanDetailRequest.setOrderIdFk(purOrderRequest.getApplyId() + "");
List<PurPlanDetailEntity> purApplyDetailEntityList = purPlanDetailService.getPurPlanDetailEntityList(purPlanDetailRequest);
//使用stream拷贝list
List<PurOrderDetailEntity> purOrderDetailEntityList = purApplyDetailEntityList.stream()
.map(e-> {
.map(e -> {
PurOrderDetailEntity d = new PurOrderDetailEntity();
BeanUtils.copyProperties(e, d);
return d;
})
.collect(Collectors.toList());
for (PurOrderDetailEntity obj:purOrderDetailEntityList){
obj.setOrderIdFk(purOrderRequest.getId()+"");
for (PurOrderDetailEntity obj : purOrderDetailEntityList) {
obj.setOrderIdFk(purOrderRequest.getId() + "");
}
//获取详情表信息
PurOrderDetailRequest PurOrderDetailRequest=new PurOrderDetailRequest();
PurOrderDetailRequest PurOrderDetailRequest = new PurOrderDetailRequest();
PurOrderDetailRequest.setOrderIdFk(purOrderRequest.getId() + "");
List<PurOrderDetailEntity> purOrderDetailEntities=purOrderDetailService.getPurOrderDetailEntityList(PurOrderDetailRequest);
List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailService.getPurOrderDetailEntityList(PurOrderDetailRequest);
List<Long> ids=new ArrayList<>();
for (PurOrderDetailEntity obj:purOrderDetailEntities){
for (PurOrderDetailEntity obj1:purOrderDetailEntityList){
if(obj.getProductId().equals(obj1.getProductId())){
List<Long> ids = new ArrayList<>();
for (PurOrderDetailEntity obj : purOrderDetailEntities) {
for (PurOrderDetailEntity obj1 : purOrderDetailEntityList) {
if (obj.getProductId().equals(obj1.getProductId())) {
//获取存在在详情表和申购单里面一样的产品
ids.add(obj.getId().longValue());
ids.add(obj.getId().longValue());
break;
}
}
}
//删除存在的产品
if(ids.size()>0){
if (ids.size() > 0) {
purOrderDetailService.deleteByIds(ids);
}
boolean falg= purOrderDetailService.insertPurOrderDetailEntity(purOrderDetailEntityList);
if(falg){
boolean falg = purOrderDetailService.insertPurOrderDetailEntity(purOrderDetailEntityList);
if (falg) {
//查询申购单
return ResultVOUtils.success("添加成功");
}else{
} else {
return ResultVOUtils.success("添加失败");
}
}
@ -295,14 +300,14 @@ public class PurOrderController {
*
*/
@PostMapping("/purchase/order/addOrderDetail")
public BaseResponse addOrderDetail(@RequestBody PurOrderDetailEntity purOrderDetailEntity) {
public BaseResponse addOrderDetail(@RequestBody PurOrderDetailEntity purOrderDetailEntity) {
boolean falg=purOrderDetailService.insert(purOrderDetailEntity);
if(falg){
return ResultVOUtils.success("添加成功");
}else {
return ResultVOUtils.success("添加失败");
}
boolean falg = purOrderDetailService.insert(purOrderDetailEntity);
if (falg) {
return ResultVOUtils.success("添加成功");
} else {
return ResultVOUtils.success("添加失败");
}
}
@ -314,13 +319,13 @@ public class PurOrderController {
@PostMapping("/purchase/order/add")
public BaseResponse add() {
Long userId = customerService.getUserId();
PurOrderEntity purOrderEntity= new PurOrderEntity();
PurOrderEntity purOrderEntity = new PurOrderEntity();
purOrderEntity.setCreateUser(userId + "");
purOrderEntity.setCreateTime(new Date());
purOrderEntity.setUpdateTime(new Date());
purOrderEntity.setUpdateUser(userId + "");
purOrderService.insert(purOrderEntity);
Long id=purOrderEntity.getId();
Long id = purOrderEntity.getId();
return ResultVOUtils.success(id);
}
@ -331,13 +336,13 @@ public class PurOrderController {
@PostMapping("/purchase/order/delOrderDetailAll")
public BaseResponse delApplyDetailAll(@RequestBody PurApplyEntity purApplyEntity) {
if(purApplyEntity.getId()!=null){
if (purApplyEntity.getId() != null) {
purOrderService.deleteById(purApplyEntity.getId());
purOrderDetailService.deleteByOrderId(purApplyEntity.getId() + "" );
}else {
return ResultVOUtils.error(999,"参数有误!");
purOrderDetailService.deleteByOrderId(purApplyEntity.getId() + "");
} else {
return ResultVOUtils.error(999, "参数有误!");
}
return ResultVOUtils.success();
return ResultVOUtils.success();
}
/**
@ -349,6 +354,7 @@ public class PurOrderController {
purOrderDetailService.update(purOrderDetailEntity);
return ResultVOUtils.success("修改成功");
}
/**
*
*

@ -86,6 +86,8 @@ public class PurOrderReceiveController extends BaseController {
IoOrderService ioOrderService;
@Resource
IoOrderDetailBizService ioOrderDetailBizService;
@Resource
IoPurChangeService purChangeService;
@AuthRuleAnnotation("")
@ -252,9 +254,10 @@ public class PurOrderReceiveController extends BaseController {
receiveService.updateOrder(purReceiveEntity);
if (purReceiveEntity.getStatus() == 3) {
generateDocument(purReceiveEntity);
//进行单据流转
purChangeService.purReceiveChange(purReceiveEntity);
// generateDocument(purReceiveEntity);
}
return ResultVOUtils.success("成功");
}

@ -80,7 +80,8 @@ public class PurPlanController {
PurOrderService purOrderService;
@Resource
PurOrderDetailService purOrderDetailService;
@Resource
IoPurChangeService purChangeService;
/**
*
@ -99,7 +100,7 @@ public class PurPlanController {
purPlanEntity.setUpdateUser(userId + "");
purPlanEntity.setStatus(postPurPlanRequest.getEditStatus()); //草稿状态
if(postPurPlanRequest.getType()!=null){
if (postPurPlanRequest.getType() != null) {
String billNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.SG_ORDER, "yyyyMMdd"));
purPlanEntity.setBillNo(billNo);
}
@ -111,7 +112,6 @@ public class PurPlanController {
}
return ResultVOUtils.success("提交成功!");
}
@ -185,13 +185,14 @@ public class PurPlanController {
Long userId = customerService.getUserId();
PurPlanEntity purPlanEntity = postPurPlanRequest.getPurPlanEntity();
purPlanEntity.setUpdateTime(new Date());
purPlanEntity.setUpdateUser(userId+"");
purPlanEntity.setUpdateUser(userId + "");
purPlanEntity.setAuditUser(userId + "");
purPlanEntity.setAuditUser(userId + "");
purPlanEntity.setStatus(postPurPlanRequest.getEditStatus());
// purPlanService.update(purApplyEntity);
if(purPlanEntity.getStatus()==3){
generateDocument(purPlanEntity);
if (purPlanEntity.getStatus() == 3) {
purChangeService.purPlanChange(purPlanEntity);
// generateDocument(purPlanEntity);
}
@ -257,115 +258,115 @@ public class PurPlanController {
}
//根据单据生成新单据
public Boolean generateDocument(PurPlanEntity purPlanEntity){
BasicBusTypeChangeEntity basicBusTypeChangeEntity=new BasicBusTypeChangeEntity();
public Boolean generateDocument(PurPlanEntity purPlanEntity) {
BasicBusTypeChangeEntity basicBusTypeChangeEntity = new BasicBusTypeChangeEntity();
//查询计划详情
List<PurPlanDetailEntity> purPlanDetailEntityList=purPlanDetailService.findByOrderId(purPlanEntity.getId()+"");
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
PurOrderEntity purOrderEntity=new PurOrderEntity();
if(purPlanEntity.getStatus()==3){
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.setCreateTime(timeProcess(purPlanEntity.getCreateTime(),basicBusTypeChangeEntity.getBusBeforeTime()));
purOrderEntity.setUpdateUser(purPlanEntity.getAuditUser());
purOrderEntity.setUpdateTime(timeProcess(purPlanEntity.getCreateTime(),basicBusTypeChangeEntity.getBusBeforeTime()));
if(purOrderEntity.getStatus()==3){
purOrderEntity.setAuditUser("");
purOrderEntity.setAuditTime(new Date());
}
//插入订单主表
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());
List<PurPlanDetailEntity> purPlanDetailEntityList = purPlanDetailService.findByOrderId(purPlanEntity.getId() + "");
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
PurOrderEntity purOrderEntity = new PurOrderEntity();
if (purPlanEntity.getStatus() == 3) {
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.setCreateTime(timeProcess(purPlanEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
purOrderEntity.setUpdateUser(purPlanEntity.getAuditUser());
purOrderEntity.setUpdateTime(timeProcess(purPlanEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
if (purOrderEntity.getStatus() == 3) {
purOrderEntity.setAuditUser("");
purOrderEntity.setAuditTime(new Date());
}
//插入订单主表
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());
// purPlanEntity.sets(true);
purPlanService.update(purPlanEntity1);
}
//---------------------------------判断计划为已审核就生成采购入库单-------------------------------------------//\
//查询申购单详情
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.getInvCode());
ioOrderEntity.setInvCode(purPlanEntity.getDeptCode());
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);
}
purPlanService.update(purPlanEntity1);
}
//---------------------------------判断计划为已审核就生成采购入库单-------------------------------------------//\
//查询申购单详情
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.getInvCode());
ioOrderEntity.setInvCode(purPlanEntity.getDeptCode());
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()));
}
PurPlanEntity purPlanEntity1=new PurPlanEntity();
purPlanEntity1.setId(purPlanEntity.getId());
purPlanEntity1.setStockOrderNo(billNo.substring(0,billNo.length()-1));
purPlanService.update(purPlanEntity1);
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);
}
}
return true;
}
public Date timeProcess(Date date,Integer timeCount) {
public Date timeProcess(Date date, Integer timeCount) {
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(date);
rightNow.add(Calendar.HOUR,timeCount);
rightNow.add(Calendar.HOUR, timeCount);
Date dt1 = rightNow.getTime();
return dt1;
}
@ -391,55 +392,55 @@ public class PurPlanController {
*
*/
@PostMapping("/purchase/plan/addPlanDetailAndApply")
public BaseResponse addPlanDetailAndApply(@RequestBody PurPlanRequest purPlanRequest) {
public BaseResponse addPlanDetailAndApply(@RequestBody PurPlanRequest purPlanRequest) {
if (purPlanRequest.getApplyId() == null || purPlanRequest.getId() == null) {
return ResultVOUtils.error(999,"参数错误!");
return ResultVOUtils.error(999, "参数错误!");
}
//查询申购单详情
PurApplyDetailRequest purApplyDetailRequest=new PurApplyDetailRequest();
purApplyDetailRequest.setOrderIdFk(purPlanRequest.getApplyId()+"");
List<PurApplyDetailEntity> purApplyDetailEntityList=purApplyDetailService.selectPurApplyDetailList(purApplyDetailRequest);
PurApplyDetailRequest purApplyDetailRequest = new PurApplyDetailRequest();
purApplyDetailRequest.setOrderIdFk(purPlanRequest.getApplyId() + "");
List<PurApplyDetailEntity> purApplyDetailEntityList = purApplyDetailService.selectPurApplyDetailList(purApplyDetailRequest);
//使用stream拷贝list
List<PurPlanDetailEntity> purPlanDetailEntityList = purApplyDetailEntityList.stream()
.map(e-> {
.map(e -> {
PurPlanDetailEntity d = new PurPlanDetailEntity();
BeanUtils.copyProperties(e, d);
return d;
})
.collect(Collectors.toList());
for (PurPlanDetailEntity obj:purPlanDetailEntityList){
obj.setOrderIdFk(purPlanRequest.getId()+"");
for (PurPlanDetailEntity obj : purPlanDetailEntityList) {
obj.setOrderIdFk(purPlanRequest.getId() + "");
}
//获取详情表信息
PurPlanDetailRequest purPlanDetailRequest=new PurPlanDetailRequest();
PurPlanDetailRequest purPlanDetailRequest = new PurPlanDetailRequest();
purPlanDetailRequest.setOrderIdFk(purPlanRequest.getId() + "");
List<PurPlanDetailEntity> purApplyDetailEntities=purPlanDetailService.getPurPlanDetailEntityList(purPlanDetailRequest);
List<PurPlanDetailEntity> purApplyDetailEntities = purPlanDetailService.getPurPlanDetailEntityList(purPlanDetailRequest);
List<Long> ids=new ArrayList<>();
for (PurPlanDetailEntity obj:purApplyDetailEntities){
for (PurPlanDetailEntity obj1:purPlanDetailEntityList){
if(obj.getProductId().equals(obj1.getProductId())){
List<Long> ids = new ArrayList<>();
for (PurPlanDetailEntity obj : purApplyDetailEntities) {
for (PurPlanDetailEntity obj1 : purPlanDetailEntityList) {
if (obj.getProductId().equals(obj1.getProductId())) {
//获取存在在详情表和申购单里面一样的产品
ids.add(obj.getId().longValue());
ids.add(obj.getId().longValue());
break;
}
}
}
//删除存在的产品
if(ids.size()>0){
if (ids.size() > 0) {
purPlanDetailService.deleteByIds(ids);
}
boolean falg= purPlanDetailService.insertPurPlanDetailEntity(purPlanDetailEntityList);
if(falg){
boolean falg = purPlanDetailService.insertPurPlanDetailEntity(purPlanDetailEntityList);
if (falg) {
//查询申购单
return ResultVOUtils.success("添加成功");
}else{
} else {
return ResultVOUtils.success("添加失败");
}
}
@ -449,14 +450,14 @@ public class PurPlanController {
*
*/
@PostMapping("/purchase/plan/addPlanDetail")
public BaseResponse addPlanDetail(@RequestBody PurPlanDetailEntity purPlanDetailEntity) {
public BaseResponse addPlanDetail(@RequestBody PurPlanDetailEntity purPlanDetailEntity) {
boolean falg=purPlanDetailService.insert(purPlanDetailEntity);
if(falg){
return ResultVOUtils.success("添加成功");
}else {
return ResultVOUtils.success("添加失败");
}
boolean falg = purPlanDetailService.insert(purPlanDetailEntity);
if (falg) {
return ResultVOUtils.success("添加成功");
} else {
return ResultVOUtils.success("添加失败");
}
}
@ -468,13 +469,13 @@ public class PurPlanController {
@PostMapping("/purchase/plan/add")
public BaseResponse add() {
Long userId = customerService.getUserId();
PurPlanEntity purPlanEntity= new PurPlanEntity();
PurPlanEntity purPlanEntity = new PurPlanEntity();
purPlanEntity.setCreateUser(userId + "");
purPlanEntity.setCreateTime(new Date());
purPlanEntity.setUpdateTime(new Date());
purPlanEntity.setUpdateUser(userId + "");
purPlanService.insert(purPlanEntity);
Long id=purPlanEntity.getId();
Long id = purPlanEntity.getId();
return ResultVOUtils.success(id);
}
@ -485,13 +486,13 @@ public class PurPlanController {
@PostMapping("/purchase/plan/delPlanDetailAll")
public BaseResponse delApplyDetailAll(@RequestBody PurApplyEntity purApplyEntity) {
if(purApplyEntity.getId()!=null){
if (purApplyEntity.getId() != null) {
purPlanService.deleteById(purApplyEntity.getId());
purPlanDetailService.deleteByOrderId(purApplyEntity.getId() + "" );
}else {
return ResultVOUtils.error(999,"参数有误!");
purPlanDetailService.deleteByOrderId(purApplyEntity.getId() + "");
} else {
return ResultVOUtils.error(999, "参数有误!");
}
return ResultVOUtils.success();
return ResultVOUtils.success();
}
/**
@ -503,6 +504,7 @@ public class PurPlanController {
purPlanDetailService.update(purPlanDetailEntity);
return ResultVOUtils.success("修改成功");
}
/**
*
*

Loading…
Cancel
Save