Commit 2036bf4d by 江和松

1.采购入库单功能提交

parent 1a8f1078
......@@ -46,6 +46,13 @@ public enum DdynamicEnum {
/**
* 模块:存货档案
* 用途:存货档案下拉框
* 编写:jhs
*/
MATERIAL_RECORD_BLOCK_ID("material_record_block_id","inventCode","inventName","HPPZ006.queryMaterialComboBox"),
/**
* 模块:存货档案
* 用途:存货档案下拉框
* 编写:wwl
*/
INVENT_SPEC_BLOCK_ID("invent_spec_block_id","spec","spec","HPPZ006.queryComboBoxSpec"),
......
......@@ -26,6 +26,27 @@ public enum InventTypeEnun {
this.value = value;
}
public static String getNameByCode(String code){
String returnName = "";
switch (code){
case "1":
returnName = MATERIAL.value;
break;
case "2":
returnName = CONSUMABLE.value;
break;
case "3":
returnName = SEMI_FINISHED_PRODUCT.value;
break;
case "4":
returnName = FINISHED_PRODUCT.value;
break;
default:
break;
}
return returnName;
};
public Integer getCode() {
return code;
}
......@@ -46,20 +67,20 @@ public enum InventTypeEnun {
EiBlock block = new EiBlock("customer_type_block_id");
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>() {{
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, MATERIAL.code);
put(HPConstants.VALUE_FIELD, MATERIAL.value);
put(HPConstants.TEXT_FIELD, MATERIAL.code + HPConstants.SPLICING_SYMBOL + MATERIAL.value);
put(HPConstants.VALUE_FIELD, MATERIAL.code);
}});
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, CONSUMABLE.code);
put(HPConstants.VALUE_FIELD, CONSUMABLE.value);
put(HPConstants.TEXT_FIELD, CONSUMABLE.code + HPConstants.SPLICING_SYMBOL + CONSUMABLE.value);
put(HPConstants.VALUE_FIELD, CONSUMABLE.code);
}});
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, SEMI_FINISHED_PRODUCT.code);
put(HPConstants.VALUE_FIELD, SEMI_FINISHED_PRODUCT.value);
put(HPConstants.TEXT_FIELD, SEMI_FINISHED_PRODUCT.code + HPConstants.SPLICING_SYMBOL + SEMI_FINISHED_PRODUCT.value);
put(HPConstants.VALUE_FIELD, SEMI_FINISHED_PRODUCT.code);
}});
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, FINISHED_PRODUCT.code);
put(HPConstants.VALUE_FIELD, FINISHED_PRODUCT.value);
put(HPConstants.TEXT_FIELD, FINISHED_PRODUCT.code + HPConstants.SPLICING_SYMBOL + FINISHED_PRODUCT.value);
put(HPConstants.VALUE_FIELD, FINISHED_PRODUCT.code);
}});
}};
block.setRows(rows);
......
......@@ -20,6 +20,10 @@ public class HPConstant {
public static final String HPKC008_NUMBER = "HPKC008_NUMBER";
// 巡检单号
public static final String HPZL001_NUMBER = "HPZL001_NUMBER";
//采购入库单号
public static final String HPKC001_NUMBER = "HPKC001_NUMBER";
//生产领料单号
public static final String HPKC002_NUMBER = "HPKC002_NUMBER";
// 生产入库单号
public static final String HPKC003_PROD_NO = "HPKC003_PROD_NO";
// 生产销售单号
......
......@@ -3,11 +3,17 @@ package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC001;
import com.baosight.hpjx.hp.kc.domain.HPKC001;
import com.baosight.hpjx.hp.kc.domain.HPKC005;
import com.baosight.hpjx.hp.kc.domain.HPKC009;
import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.pz.domain.THppz004;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.hpjx.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
......@@ -15,6 +21,7 @@ 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.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
......@@ -31,17 +38,17 @@ public class ServiceHPKC001 extends ServiceBase {
*/
@Override
public EiInfo initLoad(EiInfo inInfo) {
HPKC001 HPKC001 = new HPKC001();
EiInfo outInfo = super.initLoad(inInfo, HPKC001);
outInfo.getBlock(EiConstant.resultBlock).getRows().clear();
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), null);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.WH_RECORD_QUERY_BLOCK_ID), null);
EiBlock block = outInfo.addBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, ACConstants.PARAM_WH_CODE, outInfo.getBlock(ACConstants.WH_CODE_BLOCK_ID).getRow(ACConstants.ROW_CODE_0).get(ACConstants.FIELD_VALUE));
block.setCell(ACConstants.ROW_CODE_0, ACConstants.PARAM_WH_CODE, outInfo.getBlock(ACConstants.WH_CODE_QUERY_BLOCK_ID).getRow(ACConstants.ROW_CODE_0).get(ACConstants.FIELD_VALUE));
outInfo.setBlock(InventTypeEnun.generatorEiBlock());
return outInfo;
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_QUERY_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.MATERIAL_RECORD_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_SPEC_BLOCK_ID), null);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC001().eiMetadata);
inInfo.setBlock(InventTypeEnun.generatorEiBlock());
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
......@@ -65,15 +72,31 @@ public class ServiceHPKC001 extends ServiceBase {
public EiInfo insert(EiInfo inInfo) {
try {
CommonMethod.creatorInfo(inInfo,EiConstant.resultBlock);
for (int i = 0; i < inInfo.getBlock(EiConstant.resultBlock).getRowCount(); i++) {
String documentTime = inInfo.getCellStr(EiConstant.resultBlock,i,"documentTime");
if(StringUtils.isNotBlank(documentTime)){
inInfo.setCell(EiConstant.resultBlock,i,"documentTime", StringUtil.removeHorizontalLine(documentTime));
}
inInfo.setCell(EiConstant.resultBlock,i,"status", 1);
inInfo.setCell(EiConstant.resultBlock,i,"approvalStatus", 0);
super.insert(inInfo,"HPKC001.insert");
}
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
this.checkSaveData(resultRows);
// 写入数据
for (int i = 0; i < resultRows.size(); i++) {
HPKC001 insertEntity = new HPKC001();
insertEntity.fromMap(resultRows.get(i));
// 仓库名称
Map params = new HashMap<>();
params.put("whCode", insertEntity.getWhCode());
List query = dao.query("HPPZ007.queryByWhCode", params);
insertEntity.setWhName(((HPPZ007) query.get(0)).getWhName());
//物料类型
insertEntity.setMaterialTypeName(InventTypeEnun.getNameByCode(insertEntity.getMaterialType()));
// 生成单据号
insertEntity.setDocumentCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC001_NUMBER));
// 去除日期字符串中的-
insertEntity.setDocumentTime(StringUtil.removeHorizontalLine(insertEntity.getDocumentTime()));
insertEntity.setStatus(1);
insertEntity.setApprovalStatus(0);
DaoUtils.insert("HPKC001.insert", insertEntity);
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (PlatException e) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!原因参见详细错误描述!");
......@@ -85,6 +108,23 @@ public class ServiceHPKC001 extends ServiceBase {
return query(inInfo);
}
/**
* 校验保存的数据
*
* @param resultRows
*/
private void checkSaveData(List<Map> resultRows) {
for (int i = 0; i < resultRows.size(); i++) {
HPKC001 entity = new HPKC001();
entity.fromMap(resultRows.get(i));
AssertUtils.isEmpty(entity.getMaterialType(), "物料类型不能为空");
AssertUtils.isEmpty(entity.getMaterialCode(), "物料不能为空");
AssertUtils.isEmpty(entity.getWhCode(), "仓库不能为空");
}
}
/**
* 修改操作.
......@@ -92,25 +132,31 @@ public class ServiceHPKC001 extends ServiceBase {
@Override
public EiInfo update(EiInfo inInfo) {
try {
CommonMethod.creatorInfo(inInfo,EiConstant.resultBlock);
HPKC001 hpkc001 = new HPKC001();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hpkc001.fromMap(map);
String documentTime = inInfo.getCellStr(EiConstant.resultBlock,i,"documentTime");
if(StringUtils.isNotBlank(documentTime)){
inInfo.setCell(EiConstant.resultBlock,i,"documentTime", StringUtil.removeHorizontalLine(documentTime));
}
this.dao.update("HPKC001.update", hpkc001.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("修改成功!");
CommonMethod.udpateInfo(inInfo,EiConstant.resultBlock);
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
this.checkSaveData(resultRows);
// 写入数据
for (int i = 0; i < resultRows.size(); i++) {
HPKC001 updateEntity = new HPKC001();
updateEntity.fromMap(resultRows.get(i));
// 仓库名称
Map params = new HashMap<>();
params.put("whCode", updateEntity.getWhCode());
List query = dao.query("HPPZ007.queryByWhCode", params);
updateEntity.setWhName(((HPPZ007) query.get(0)).getWhName());
//物料类型
updateEntity.setMaterialTypeName(InventTypeEnun.getNameByCode(updateEntity.getMaterialType()));
DaoUtils.update("HPKC001.update", updateEntity);
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (PlatException e) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!原因参见详细错误描述!");
inInfo.setDetailMsg(e.getMessage());
logError("修改失败", e.getMessage());
logError("新增失败", e.getMessage());
return inInfo;
}
return query(inInfo);
......
......@@ -110,8 +110,8 @@
UPDATE hpjx.t_hpkc001
SET
UPDATED_BY = #updatedBy#,
UPDATED_BY = #updatedBy#,
UPDATED_BY = #updatedBy#
UPDATED_NAME = #updatedName#,
UPDATED_TIME = #updatedTime#
<isNotEmpty property="companyCode">
,COMPANY_CODE = #companyCode#
</isNotEmpty>
......
......@@ -154,4 +154,22 @@ public class ServiceHPPZ006 extends ServiceBase {
return inInfo;
}
public EiInfo queryComboBox(EiInfo eiInfo) {
Map map = new HashMap();
map.put("inventType", eiInfo.getString("inventType"));
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.INVENT_RECORD_BLOCK_ID);
CommonMethod.initBlock(eiInfo, list, map);
return eiInfo;
}
public EiInfo queryMaterialComboBox(EiInfo eiInfo) {
Map map = new HashMap();
map.put("inventType", eiInfo.getString("inventType"));
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.MATERIAL_RECORD_BLOCK_ID);
CommonMethod.initBlock(eiInfo, list, map);
return eiInfo;
}
}
package com.baosight.hpjx.hp.pz.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
......@@ -10,10 +13,7 @@ import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class ServiceHPPZ007 extends ServiceBase {
......@@ -21,6 +21,7 @@ public class ServiceHPPZ007 extends ServiceBase {
HPPZ007 hppz007 = new HPPZ007();
EiInfo outInfo = super.initLoad(inInfo, hppz007);
outInfo.addBlock(EiConstant.resultBlock).addBlockMeta(hppz007.eiMetadata);
inInfo.setBlock(InventTypeEnun.generatorEiBlock());
return inInfo;
}
......@@ -135,4 +136,13 @@ public class ServiceHPPZ007 extends ServiceBase {
return inInfo;
}
public EiInfo queryComboBox(EiInfo eiInfo) {
Map map = new HashMap();
map.put("whType", eiInfo.getString("whType"));
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.WH_RECORD_BLOCK_ID);
CommonMethod.initBlock(eiInfo, list, map);
return eiInfo;
}
}
......@@ -116,6 +116,21 @@
ORDER BY INVENT_CODE
</select>
<select id="queryMaterialComboBox" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
SELECT DISTINCT
INVENT_CODE as "inventCode",
INVENT_NAME as "inventName"
FROM hpjx.t_hppz006 WHERE STATUS=1
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
</isNotEmpty>
ORDER BY INVENT_CODE
</select>
<!-- 规格下拉框 -->
<select id="queryComboBoxSpec" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT DISTINCT
......@@ -127,6 +142,9 @@
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
</isNotEmpty>
ORDER BY ID
</select>
......
......@@ -99,6 +99,21 @@ public class CommonMethod {
}
}
public static void udpateInfo(EiInfo eiInfo, String resultBlock){
EiBlock block=eiInfo.getBlock(resultBlock);
String userId = UserSession.getLoginName();
String userName = UserSession.getLoginCName();
String time = DateUtils.curDateTimeStr14();
for(int i=0; i < block.getRowCount(); i++){
//TODO 公司代码待补充
block.setCell(i, HPConstants.SQL_FIELD_COMPANYCODE, "");
block.setCell(i, HPConstants.SQL_FIELD_UPDATED_BY, userId);
block.setCell(i, HPConstants.SQL_FIELD_UPDATED_NAME, userName);
block.setCell(i, HPConstants.SQL_FIELD_UPDATED_TIME, time);
}
}
public static void updateuserInfo(EiInfo eiInfo, String resultBlock){
EiBlock block=eiInfo.getBlock(resultBlock);
......
......@@ -25,39 +25,25 @@
<EF:EFGrid blockId="result" autoDraw="false" isFloat="true" autoFit="true">
<EF:EFColumn ename="id" cname="主键id" hidden="true"/>
<EF:EFColumn ename="documentTime" cname="单据日期" editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyy-MM-dd']" width="100" required="true"/>
<EF:EFColumn ename="documentCode" cname="采购入库单号" width="100" readonly="false" align="center" required="true"/>
<EF:EFComboColumn ename="whCode"
cname="仓库编码"
columnTemplate="#=textField#"
itemTemplate="#=textField#"
blockName="wh_record_block_id"
textField="textField"
valueField="valueField"
align="center"
filter="contains"
width="100"
required="true"
>
</EF:EFComboColumn>
<EF:EFColumn ename="whName" cname="仓库名称" width="120" readonly="true" align="center" enable="false" required="true"/>
<EF:EFColumn ename="documentCode" cname="采购入库单号" width="100" readonly="false" align="center" required="false" enable="false" />
<EF:EFComboColumn ename="materialType"
cname="物料类型"
columnTemplate="#=textField#"
itemTemplate="#=textField#"
blockName="customer_type_block_id"
textField="textField"
valueField="textField"
valueField="valueField"
align="center"
filter="contains"
width="100"
required="true"
>
</EF:EFComboColumn>
<EF:EFColumn ename="materialTypeName" cname="物料类型名称" width="100" readonly="true" enable="false" required="true" />
<EF:EFColumn ename="whCode" cname="仓库名称" width="100" readonly="false" required="true"/>
<EF:EFColumn ename="whName" cname="仓库名称" width="100" readonly="false" hidden="true"/>
<EF:EFColumn ename="materialCode" cname="物料编码" width="100" readonly="false" required="true"/>
<EF:EFColumn ename="materialName" cname="物料名称" width="100" readonly="false" required="true"/>
<EF:EFColumn ename="materialName" cname="物料名称" width="100" readonly="false" enable="false" required="true"/>
<EF:EFColumn ename="unit" cname="单位" width="80" readonly="false" align="center" enable="false" required="true"/>
<EF:EFColumn ename="spec" cname="规格" width="120" readonly="false" align="center" required="true"/>
<EF:EFColumn ename="unit" cname="单位" width="80" readonly="false" align="center" required="true"/>
<EF:EFColumn ename="quantity" cname="数量" width="80" defaultValue="0" data-regex="/^[0-9]\\\d*$/" data-errorprompt="请输入正整数" readonly="false" align="right" required="true"/>
<EF:EFColumn ename="weight" cname="重量" defaultValue="0" data-rules="number" maxLength="20" width="100" align="right" readonly="false"/>
<EF:EFColumn ename="remarks" cname="备注" width="100" readonly="false"/>
......
......@@ -24,10 +24,21 @@
</EF:EFRegion>
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="no">
<EF:EFGrid blockId="result" autoDraw="no" >
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="whType" cname="仓库类型"/>
<EF:EFComboColumn ename="whType"
cname="仓库类型"
columnTemplate="#=textField#"
itemTemplate="#=textField#"
blockName="customer_type_block_id"
textField="textField"
valueField="valueField"
align="center"
filter="contains"
width="100"
required="true"
>
</EF:EFComboColumn>
<EF:EFColumn ename="whCode" cname="仓库编码"/>
<EF:EFColumn ename="whName" cname="仓库名称"/>
......
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