Commit e1ff59ba by liuyang

优化设备台账

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