Commit 7437525d by liuyang

2024-10-08 委外出库单

parent 89f8d730
package com.baosight.hggp.hg.kc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.kc.constant.HgKcSqlConstant;
import com.baosight.hggp.hg.kc.domain.HGKC015;
import com.baosight.hggp.hg.kc.domain.HGKC015A;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.sc.constant.HgScSqlConstant;
import com.baosight.hggp.hg.sc.domain.HGSC010;
import com.baosight.hggp.hg.sc.domain.HGSC010B;
import com.baosight.hggp.hg.sc.tools.HGSCTools;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.*;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.lang.StringUtils;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/10/6
* @description 委外出库单
*/
public class ServiceHGKC015 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID, DdynamicEnum.USER_BLOCK_ID));
EiInfoUtils.addBlock(inInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGKC015().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询
*
* @param inInfo
* @return
*/
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String outDate = MapUtils.getString(queryMap, HGKC015.FIELD_OUT_DATE);
if (StringUtils.isNotBlank(outDate)) {
queryMap.put(HGKC015.FIELD_OUT_DATE, StringUtil.removeHorizontalLine(outDate));
}
inInfo = super.query(inInfo, HGKC015.QUERY, new HGKC015());
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "委外出库单", operType = "删除", operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
List<HGKC015> hgkc015List = MapUtils.toDaoEPBases(inInfo, HGKC015.class);
List<Long> ids = ObjectUtils.listEpKey(hgkc015List, HGKC015.FIELD_ID);
List<HGKC015A> hgkc015As = HGKCTools.HgKc015a.getByParentId(ids);
List<String> contractCodes = ObjectUtils.listEpKey(hgkc015As, HGKC015A.FIELD_CONTRACT_CODE);
List<HGSC010B> hgsc010Bs = HGSCTools.Hgsc010b.getByContractCode(contractCodes);
for (HGKC015 hgkc015: hgkc015List) {
AssertUtils.isTrue(hgkc015.getStatus().equals(CommonConstant.YesNo.YES_1), "当前委外任务已提交,不允许删除!");
if (Objects.nonNull(hgkc015As)){
List<HGKC015A> hgkc015AList = hgkc015As.stream().filter(hgkc015A -> hgkc015A.getParentId().equals(hgkc015.getId())).collect(Collectors.toList());
HGKCTools.HgKc015a.deleteByParentId(hgkc015AList, hgsc010Bs);
}
DaoUtils.update(HGKC015.DELETE, hgkc015);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "委外出库单", operType = "保存", operDesc = "保存操作")
public EiInfo save(EiInfo inInfo){
try {
List<Map> resultMaps = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultMap: resultMaps) {
HGKC015 hgkc015 = new HGKC015();
hgkc015.fromMap(resultMap);
if(Objects.nonNull(hgkc015.getId())&&hgkc015.getId()!=0){
this.modify(hgkc015);
}else {
this.add(hgkc015);
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
public void add(HGKC015 hgkc015) {
hgkc015.setOutCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.OUT_CODE));
DaoUtils.insert(HGKC015.INSERT, hgkc015);
}
public void modify(HGKC015 hgkc015) {
DaoUtils.update(HGKC015.UPDATE, hgkc015);
}
@OperationLogAnnotation(operModul = "委外出库单", operType = "提交", operDesc = "提交操作")
public EiInfo updateStatus(EiInfo inInfo) {
int i = 0;
try {
List<HGKC015> resultMaps = MapUtils.toDaoEPBases(inInfo, HGKC015.class);
List<Long> ids = ObjectUtils.listEpKey(resultMaps, HGKC015.FIELD_ID);
List<HGKC015A> hgkc015AList = HGKCTools.HgKc015a.getByParentId(ids);
List<HGSC010B> hgsc010Bs = HGSCTools.Hgsc010b.getByContractCode(ObjectUtils.listEpKey(hgkc015AList, HGKC015A.FIELD_CONTRACT_CODE));
AssertUtils.isTrue(Objects.isNull(hgkc015AList), "请先添加出库明细");
for (HGKC015 hgkc015: resultMaps) {
List<HGKC015A> hgkc15As = hgkc015AList.stream().filter(item -> item.getParentId().equals(hgkc015.getId())).collect(Collectors.toList());
AssertUtils.isTrue(hgkc15As.size()<= 0, "请先添加出库明细");
hgkc015.setStatus(CommonConstant.YesNo.YES_1);
DaoUtils.update(HgKcSqlConstant.HgKc015.UPDATE_STATUS, hgkc015);
for (HGKC015A hgkc015A: hgkc15As) {
HGSC010 hgsc010 = new HGSC010();
hgsc010.setContractCode(hgkc015A.getContractCode());
BigDecimal remainingQty = hgsc010Bs.stream().filter(item -> item.getContractCode().equals(hgkc015A.getContractCode())).map(HGSC010B::getRemainingQty).reduce(BigDecimal.ZERO,BigDecimal::add);
if (remainingQty.compareTo(BigDecimal.ZERO) == 0){
hgsc010.setOutStatus(HGConstant.ScOutStatus.S_2);
}else if (remainingQty.compareTo(BigDecimal.ZERO) > 0){
hgsc010.setOutStatus(HGConstant.ScOutStatus.S_1);
}else{
hgsc010.setOutStatus(HGConstant.ScOutStatus.S_0);
}
DaoUtils.update(HgScSqlConstant.HgSc010.UPDATE_OUT_STATUS, hgsc010);
}
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(resultMaps.size()), I18nMessages.getText("label.update", "提交")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "提交失败");
}
return inInfo;
}
}
package com.baosight.hggp.hg.kc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.common.InventTypeDetailEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.kc.domain.HGKC015;
import com.baosight.hggp.hg.kc.domain.HGKC015A;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.pz.domain.HGPZ004;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.sc.domain.HGSC010A;
import com.baosight.hggp.hg.sc.domain.HGSC010B;
import com.baosight.hggp.hg.sc.tools.HGSCTools;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.*;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/10/6
* @description 委外出库单明细
*/
public class ServiceHGKC015A extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo,
Arrays.asList(
DdynamicEnum.WH_RECORD_BLOCK_ID,
DdynamicEnum.INVENT_TYPE_BLOCK_ID));
CommonMethod.initBlock(inInfo,
Arrays.asList(DdynamicEnum.INVENT_RECORD_BOX_BLOCK_ID),
new HashMap<String, Object>(){{
put(HGPZ005.FIELD_STATUS,1);
put(HGPZ004.FIELD_INVENT_TYPE_DETAILS, Arrays.asList(InventTypeDetailEnum.COMPONENT.getCode(),InventTypeDetailEnum.RAW.getCode()));
}}, false);
EiInfoUtils.addBlock(inInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGSC010A().eiMetadata);
inInfo.addBlock(CommonConstant.Field.DETAIL).addBlockMeta(new HGSC010B().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询
*
* @param inInfo
* @return
*/
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
inInfo = super.query(inInfo, HGKC015A.QUERY, new HGKC015A());
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "委外出库单", operType = "保存", operDesc = "保存操作")
public EiInfo save(EiInfo inInfo){
try {
List<Map> resultMaps = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultMap: resultMaps) {
HGKC015A hgkc015a = new HGKC015A();
hgkc015a.fromMap(resultMap);
this.add(hgkc015a);
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
public void add(HGKC015A hgkc015a) {
hgkc015a.setOutCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.OUT_CODE));
DaoUtils.insert(HGKC015A.INSERT, hgkc015a);
}
public void modify(HGKC015A hgkc015a) {
DaoUtils.update(HGKC015A.UPDATE, hgkc015a);
}
@OperationLogAnnotation(operModul = "委外出库单", operType = "删除", operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
List<HGKC015A> hgkc015List = MapUtils.toDaoEPBases(inInfo, HGKC015A.class);
List<Long> ids = ObjectUtils.listEpKey(hgkc015List, HGKC015A.FIELD_PARENT_ID);
List<HGKC015> hgkc015 = HGKCTools.HgKc015.getByParentId(ids);
AssertUtils.isTrue(hgkc015!=null && hgkc015.get(0).getStatus().equals(CommonConstant.YesNo.YES_1), "当前委外任务已提交,不允许删除!");
List<String> contractCodes = ObjectUtils.listEpKey(hgkc015List, HGKC015A.FIELD_CONTRACT_CODE);
List<HGSC010B> hgsc010Bs = HGSCTools.Hgsc010b.getByContractCode(contractCodes);
HGKCTools.HgKc015a.deleteByParentId(hgkc015List, hgsc010Bs);
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
}
package com.baosight.hggp.hg.kc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.kc.domain.HGKC015A;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.sc.domain.HGSC010B;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/10/6
* @description 选择委外加工单
*/
public class ServiceHGKC015B extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID, DdynamicEnum.USER_BLOCK_ID,DdynamicEnum.INVENT_TYPE_BLOCK_ID));
EiInfoUtils.addBlock(inInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGSC010B().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
queryMap.put("isRemainingQty", "true");
queryMap.remove("parentId");
inInfo = super.query(inInfo, HGSC010B.QUERY, new HGSC010B());
List<HGSC010B> resultBlock = MapUtils.toDaoEPBases(inInfo, HGSC010B.class);
resultBlock.forEach(hgsc010a -> {
hgsc010a.setOutQty(BigDecimal.ZERO);
hgsc010a.setOutWeight(BigDecimal.ZERO);
});
inInfo.getBlock(EiConstant.resultBlock).setRows(resultBlock);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "委外出库单", operType = "保存", operDesc = "保存操作")
public EiInfo save(EiInfo inInfo){
try {
Map paramMap = EiInfoUtils.getFirstRow(inInfo);
List<Map> resultMaps = inInfo.getBlock(EiConstant.resultBlock).getRows();
//List<String> contractCodes = ObjectUtils.listKey(resultMaps, HGKC014A.FIELD_CONTRACT_CODE);
List<HGKC015A> hgkc015AList = HGKCTools.HgKc015a.getByParentId((Arrays.asList(Long.parseLong(paramMap.get("parentId").toString()))));
for (Map resultMap: resultMaps) {
DaoUtils.update(HGSC010B.UPDATE, resultMap);
HGKC015A hgkc015a = new HGKC015A();
hgkc015a.fromMap(resultMap);
List<HGKC015A> hgkc015As = new ArrayList<>();
if (hgkc015AList != null){
hgkc015As = hgkc015AList.stream().filter(hgkc015A -> hgkc015A.getContractCode().equals(hgkc015a.getContractCode())
&& hgkc015A.getInventCode().equals(hgkc015a.getInventCode())
&& hgkc015A.getSpec().equals(hgkc015a.getSpec())
&& hgkc015A.getOutCode().equals(paramMap.get(HGKC015A.FIELD_OUT_CODE))
).collect(Collectors.toList());
}
if (hgkc015As.size() > 0){
HGKC015A kc015a = hgkc015As.get(0);
kc015a.setOutQty(kc015a.getOutQty().add(hgkc015a.getOutQty()));
kc015a.setOutWeight(kc015a.getOutWeight().add(hgkc015a.getOutWeight()));
DaoUtils.update(HGKC015A.UPDATE, kc015a);
}else {
hgkc015a.setParentId(Long.parseLong(paramMap.get("parentId").toString()));
hgkc015a.setCompanyCode(paramMap.get("companyCode").toString());
hgkc015a.setCompanyName(paramMap.get("companyName").toString());
hgkc015a.setWhCode(paramMap.get("whCode").toString());
hgkc015a.setWhName(paramMap.get("whName").toString());
hgkc015a.setOutCode(paramMap.get("outCode").toString());
this.add(hgkc015a);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
public void add(HGKC015A hgkc015a) {
hgkc015a.setId(null);
hgkc015a.setUpdatedBy(null);
hgkc015a.setUpdatedName(null);
hgkc015a.setUpdatedTime(null);
hgkc015a.setCreatedBy(null);
hgkc015a.setCreatedName(null);
hgkc015a.setCreatedTime(null);
hgkc015a.setDepCode(null);
DaoUtils.insert(HGKC015A.INSERT, hgkc015a);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment