Commit 7bbe9a1e by yukang

处理相关BUG

parent be982b8d
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC002;
import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.hp.sc.domain.HPSC006;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.util.*;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 生产领料挑选库存
*
* @author:songx
* @date:2022/7/11,11:08
*/
public class ServiceHPKC002B extends ServiceEPBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.RAW.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "库存查询", operType = "查询", operDesc = "生产领料单-库存查询-初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = new HashMap();
queryMap.put("inventTypes", DEFAULT_INVENT_CODE);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), queryMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_NAME_BLOCK_ID), queryMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_SPEC_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SPEC_NAME_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SPEC_NAME_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID), null, false);
String hpsc006Id = inInfo.getString("inqu_status-0-hpsc006Id");
if (StringUtils.isNotBlank(hpsc006Id)) {
inInfo.set("inqu_result-0-hpsc006Id", hpsc006Id);
}
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC010().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询数据列表
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "库存查询", operType = "查询", operDesc = "生产领料单-库存查询-查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
queryRow.put("inventTypes", DEFAULT_INVENT_CODE);
inInfo = super.query(inInfo, HPKC010.QUERY, new HPKC010());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 生成出库单
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "库存查询",operType = "插入",operDesc = "生产领料单-库存查询-生成出库单")
public EiInfo select(EiInfo inInfo) {
try {
String hpsc006Id = inInfo.getString("inqu_result-0-hpsc006Id");
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 库存ID
List<Long> ids = ObjectUtils.listKey(resultRows, "id");
// 行锁
HPKCTools.HpKc010.lock(ids);
// 获取库存信息
Map<Long, HPKC010> dbKc010Map = HPKCTools.HpKc010.map(ids);
// 状态校验
this.checkData(resultRows, dbKc010Map);
// 生成销售库单
this.saveData(resultRows, dbKc010Map, hpsc006Id);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "生成领料单失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param resultRows
* @param dbKc010Map
*/
private void checkData(List<Map> resultRows, Map<Long, HPKC010> dbKc010Map) {
for (Map row : resultRows) {
Long id = MapUtils.getLong(row, "id");
HPKC010 dbKc010 = dbKc010Map.get(id);
AssertUtils.isNull(dbKc010, "库存号[" + id + "]不存在!");
// 校验数量
BigDecimal applyAmount = MapUtils.getBigDecimal(row, "applyAmount");
AssertUtils.isGt(applyAmount, dbKc010.getAmount(),
"库存号[" + id + "]可用数量不足!");
}
}
/**
* 保存数据
*
* @param resultRows
* @param dbKc010Map
*/
private void saveData(List<Map> resultRows, Map<Long, HPKC010> dbKc010Map, String hpsc006Id) {
for (Map row : resultRows) {
BigDecimal applyAmount = MapUtils.getBigDecimal(row, "applyAmount");
String applyRemark = MapUtils.getString(row, "applyRemark");
String projCode = MapUtils.getString(row, "projCode");
Long kcId = MapUtils.getLong(row, "id");
HPKC010 dbKc010 = dbKc010Map.get(kcId);
HPKC002 newKc002 = BeanUtils.copy(dbKc010, HPKC002.class);
newKc002.setReqNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC002_NUMBER));
newKc002.setReceiptDate(DateUtils.shortDate());
newKc002.setAmount(applyAmount);
newKc002.setWeight(dbKc010.getUnitWeight().multiply(applyAmount));
newKc002.setRemark(applyRemark);
newKc002.setKcId(kcId);
newKc002.setDeleteFlag(CommonConstant.YesNo.NO_0);
if (StringUtils.isNotBlank(hpsc006Id)) {
HPSC006 HPSC006 = HPSCTools.Hpsc006.getById(NumberUtils.toLong(hpsc006Id));
newKc002.setHpsc006Id(HPSC006.getId());
newKc002.setProjCode(HPSC006.getProjCode());
}else{
newKc002.setProjCode(projCode);
}
DaoUtils.insert(HPKC002.INSERT, newKc002);
// 修改库存数量
HPKCTools.updateStock(newKc002.getWhCode(), newKc002.getInventRecordId(),
newKc002.getAmount().negate(), dbKc010.getUnitWeight(), newKc002.getWeight().negate());
}
}
}
......@@ -56,7 +56,7 @@ let select = function () {
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据生成出库单吗? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPKC002A", "select",
JSUtils.submitGridsData("result", "HPKC002B", "select",
true, function (e) {
var status = e.getStatus();
if (status !== -1) {
......
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