Commit e1ff59ba by liuyang

优化设备台账

parent c8145030
...@@ -27,6 +27,7 @@ import java.util.Arrays; ...@@ -27,6 +27,7 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @author LiuYang * @author LiuYang
...@@ -97,11 +98,15 @@ public class ServiceHGSB001 extends ServiceEPBase { ...@@ -97,11 +98,15 @@ public class ServiceHGSB001 extends ServiceEPBase {
@OperationLogAnnotation(operModul = "设备台账",operType = "保存",operDesc = "保存操作") @OperationLogAnnotation(operModul = "设备台账",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) { public EiInfo save(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<HGSB001> resultRows = MapUtils.toDaoEPBases(inInfo,HGSB001.class);
List<String> groupCodes = resultRows.stream().map(HGSB001::getGroupCode).collect(Collectors.toList());
List<Org> groupOrgs = HGXSTools.XsOrg.list(groupCodes);
// 写入数据 // 写入数据
for (int i = 0; i < resultRows.size(); i++) { for (HGSB001 hgsb001 : resultRows) {
HGSB001 hgsb001 = new HGSB001(); Map<String, Org> orgMap = groupOrgs.stream().filter(org -> org.getOrgId().equals(hgsb001.getGroupCode())).collect(Collectors.toMap(Org::getOrgId, org -> org));
hgsb001.fromMap(resultRows.get(i)); if (!orgMap.isEmpty()){
hgsb001.setFactoryCode(orgMap.get(hgsb001.getGroupCode()).getFactoryCode());
}
if (hgsb001.getId() == null || hgsb001.getId() == 0) { if (hgsb001.getId() == null || hgsb001.getId() == 0) {
this.add(hgsb001); this.add(hgsb001);
} else { } else {
......
...@@ -179,6 +179,9 @@ ...@@ -179,6 +179,9 @@
<isNotEmpty prepend=" AND " property="address"> <isNotEmpty prepend=" AND " property="address">
ADDRESS = #address# ADDRESS = #address#
</isNotEmpty> </isNotEmpty>
<isNotEmpty prepend=" AND " property="deviceCodes">
DEVICE_CODE IN <iterate close=")" open="(" conjunction="," property="deviceCodes">#deviceCodes[]#</iterate>
</isNotEmpty>
</sql> </sql>
<select id="query" parameterClass="java.util.HashMap" <select id="query" parameterClass="java.util.HashMap"
......
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