Browse Source

修改合并内容问题

zk 1 day ago
parent
commit
e825cb4b32

+ 69 - 38
ghjg-item-datashare-server/src/main/java/com/shanghaichengdi/ghjgitem/controller/SIPGDataTransportController.java

@@ -2,8 +2,8 @@ package com.shanghaichengdi.ghjgitem.controller;
 
 
 import cn.hutool.json.JSON;
+import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -67,6 +67,9 @@ public class SIPGDataTransportController extends CommonController  {
         List<TransportSgDwNzxBoat> transportSgDwNzxBoats= JSONUtil.toList(paramJsonData,TransportSgDwNzxBoat.class);
         if (transportSgDwNzxBoats!=null && transportSgDwNzxBoats.size()>0)
         {
+            transportSgDwNzxBoats.forEach(i -> {
+                i.setUpdateTime(new Date());
+            });
             TransportSgDwNzxBoat sgDwNzxBoat=transportSgDwNzxBoats.get(0);
             //获取完工时间
             Date date=sgDwNzxBoat.getNzxAendtm();
@@ -94,13 +97,14 @@ public class SIPGDataTransportController extends CommonController  {
                             Map<List<Object>, List<TransportSgBaseNumber>> lockData = islocks.stream().collect(Collectors.groupingBy(lockDataKey, Collectors.toList()));
 
                             if (updata != null && updata.keySet() != null && updata.keySet().size() > 0) {
-                                StringBuilder stringBuilder = new StringBuilder();
+                                List<Long> stringsFilterAll =new ArrayList<>();
                                 List<TransportSgDwNzxBoat> needSaves = new ArrayList<>();
                                 updata.keySet().forEach(i -> {
                                     if (lockData.keySet().contains(i))    //如果过滤数据一致
                                     {
                                         List<Long> stringsFilter = updata.get(i).stream().map(TransportSgDwNzxBoat::getNzxSchPkid).collect(Collectors.toList());
-                                        stringBuilder.append("[" + stringsFilter.toString() + "]");
+                                        stringsFilterAll.addAll(stringsFilter);
+
                                     } else {
                                         needSaves.addAll(updata.get(i));
                                     }
@@ -111,13 +115,22 @@ public class SIPGDataTransportController extends CommonController  {
                                 });
                                 boolean a = boatService.saveOrUpdateBatch(needSaves);
                                 if (a) {
-                                    String jsonString = JSONArray.toJSONString(stringBuilder.toString());
-                                    String encodedData = resultEncode(jsonString);
-                                    return ReturnMsg.success("存储成功,且部分数据已锁,无法修改,无法修改的pkId列表为data",encodedData);
+                                    if (stringsFilterAll!=null && stringsFilterAll.size()>0) {
+                                        JSONArray jsonArray = JSONUtil.parseArray(stringsFilterAll);
+                                        String encodedData = resultEncode(jsonArray.toString());
+                                        return ReturnMsg.success("存储成功,且部分数据已锁,无法修改,无法修改的pkId列表为data", encodedData);
+                                    }else {
+                                        return ReturnMsg.success("存储成功");
+                                    }
                                 } else {
-                                    String jsonString = JSONArray.toJSONString(stringBuilder.toString());
-                                    String encodedData = resultEncode(jsonString);
-                                    return ReturnMsg.error("存储失败且部分数据已锁,无法修改,无法修改的pkId列表为data",encodedData);
+                                    if (stringsFilterAll!=null && stringsFilterAll.size()>0) {
+                                        JSONArray jsonArray = JSONUtil.parseArray(stringsFilterAll);
+                                        String encodedData = resultEncode(jsonArray.toString());
+                                        return ReturnMsg.error("存储失败且部分数据已锁,无法修改,无法修改的pkId列表为data", encodedData);
+                                    }
+                                    else {
+                                        return ReturnMsg.error("存储失败,请重新尝试");
+                                    }
                                 }
                             }
                         }
@@ -159,11 +172,16 @@ public class SIPGDataTransportController extends CommonController  {
         }
         String paramJsonData = getParamJsonData(vo.getData());
         List<TransportSgDwNzxContainers> transportSgDwNzxAgents= JSONUtil.toList(paramJsonData,TransportSgDwNzxContainers.class);
-        boolean a= containersService.saveOrUpdateBatch(transportSgDwNzxAgents);
-        if (a) {
-            return ReturnMsg.success("存储成功");
+        if (transportSgDwNzxAgents!=null && transportSgDwNzxAgents.size()>0) {
+            transportSgDwNzxAgents.forEach(i->{i.setUpdateTime(new Date());});
+            boolean a = containersService.saveOrUpdateBatch(transportSgDwNzxAgents);
+            if (a) {
+                return ReturnMsg.success("存储成功");
+            } else {
+                return ReturnMsg.error("存储失败");
+            }
         }else {
-            return ReturnMsg.error("存储失败");
+            return ReturnMsg.error("无传递数据");
         }
 
     }
@@ -183,11 +201,18 @@ public class SIPGDataTransportController extends CommonController  {
         }
         String paramJsonData = getParamJsonData(vo.getData());
         List<TransportSgDwNzxAgent> transportSgDwNzxAgents= JSONUtil.toList(paramJsonData,TransportSgDwNzxAgent.class);
-           boolean a= agentService.saveOrUpdateBatch(transportSgDwNzxAgents);
-        if (a) {
-            return ReturnMsg.success("存储成功");
+        if (transportSgDwNzxAgents!=null && transportSgDwNzxAgents.size()>0) {
+            transportSgDwNzxAgents.forEach(i -> {
+                i.setUpdateTime(new Date());
+            });
+            boolean a = agentService.saveOrUpdateBatch(transportSgDwNzxAgents);
+            if (a) {
+                return ReturnMsg.success("存储成功");
+            } else {
+                return ReturnMsg.error("存储失败");
+            }
         }else {
-            return ReturnMsg.error("存储失败");
+            return ReturnMsg.error("无传递数据");
         }
     }
 
@@ -218,10 +243,9 @@ public class SIPGDataTransportController extends CommonController  {
             int count=1;
             if (sgSyncStatuses.getSyncStatus()==1 && sgSyncStatuses.getSyncUpdateStatus() == 0) {
                 LambdaQueryWrapper<TransportSgBaseNumber> sgBaseNumberLambdaQueryWrapper=new LambdaQueryWrapper<>();
-                sgBaseNumberLambdaQueryWrapper.gt(TransportSgBaseNumber::getBaseYear,sgSyncStatuses.getSyncYear());
-                sgBaseNumberLambdaQueryWrapper.gt(TransportSgBaseNumber::getBaseQuarter,sgSyncStatuses.getSyncQuarter());
+                sgBaseNumberLambdaQueryWrapper.eq(TransportSgBaseNumber::getBaseYear,sgSyncStatuses.getSyncYear());
+                sgBaseNumberLambdaQueryWrapper.eq(TransportSgBaseNumber::getBaseQuarter,sgSyncStatuses.getSyncQuarter());
                 baseNumberService.remove(sgBaseNumberLambdaQueryWrapper);
-
                 Calendar startDate = DateUtils.getQuarterStart(sgSyncStatuses.getSyncYear(), sgSyncStatuses.getSyncQuarter());
                 Calendar endDate = DateUtils.getQuarterEnd(sgSyncStatuses.getSyncYear(), sgSyncStatuses.getSyncQuarter());
                 PageHelper.startPage(count, pageSize);
@@ -283,41 +307,47 @@ public class SIPGDataTransportController extends CommonController  {
                 }
             }
             else if (sgSyncStatuses.getSyncStatus()==1 && sgSyncStatuses.getSyncUpdateStatus() == 1){
+                //只计算未锁定的,已锁定的不能删除
+                LambdaQueryWrapper<TransportSgBaseNumber> sgBaseNumberLambdaQueryWrapper=new LambdaQueryWrapper<>();
+                sgBaseNumberLambdaQueryWrapper.eq(TransportSgBaseNumber::getBaseYear,sgSyncStatuses.getSyncYear());
+                sgBaseNumberLambdaQueryWrapper.eq(TransportSgBaseNumber::getBaseQuarter,sgSyncStatuses.getSyncQuarter());
+                sgBaseNumberLambdaQueryWrapper.isNull(TransportSgBaseNumber::getBaseNotup);
+                baseNumberService.remove(sgBaseNumberLambdaQueryWrapper);
+
                 Calendar startDate = DateUtils.getQuarterStart(sgSyncStatuses.getSyncYear(), sgSyncStatuses.getSyncQuarter());
                 Calendar endDate = DateUtils.getQuarterEnd(sgSyncStatuses.getSyncYear(), sgSyncStatuses.getSyncQuarter());
                 PageHelper.startPage(count, pageSize);
                 Page<TransportSgBaseNumber> baseNumberPage = baseNumberMapper.getAllForCountDataForUpdate(startDate.getTime(), endDate.getTime());
+                PageHelper.clearPage();
                 if (baseNumberPage != null && baseNumberPage.size() > 0 && baseNumberPage.getResult() != null && baseNumberPage.getResult().size() > 0) {
-                    if (baseNumberPage.getTotal() > pageSize ){
+                    if (baseNumberPage.getTotal() > pageSize) {
                         Long totalCount = baseNumberPage.getTotal();
                         Long totalPages = (totalCount + pageSize - 1) / pageSize;
-                        for (int i = count; i <= totalPages; i++) {
+                        for (int i = 1; i <= totalPages; i++) {
+                            System.out.println("===  本次运行第:"+i+"页");
+                            PageHelper.startPage(i, pageSize);
+                            Page<TransportSgBaseNumber> baseNumberPages = baseNumberMapper.getAllForCountDataForUpdate(startDate.getTime(), endDate.getTime());
                             if (i == 1) {
-                                saveAllTransportSgBaseNumber(sgSyncStatuses.getSyncYear(), sgSyncStatuses.getSyncQuarter(), baseNumberPage.getResult(), null);
+                                saveAllTransportSgBaseNumber(sgSyncStatuses.getSyncYear(), sgSyncStatuses.getSyncQuarter(), baseNumberPages.getResult(), null);
                             } else {
-                                PageHelper.startPage(i, pageSize);
-                                Page<TransportSgBaseNumber> baseNumberPages = baseNumberMapper.getAllForCountData(startDate.getTime(), endDate.getTime());
                                 saveAllTransportSgBaseNumber(sgSyncStatuses.getSyncYear(), sgSyncStatuses.getSyncQuarter(), baseNumberPages.getResult(), null);
                             }
+                            PageHelper.clearPage();
                         }
                     } else {
                         saveAllTransportSgBaseNumber(sgSyncStatuses.getSyncYear(), sgSyncStatuses.getSyncQuarter(), baseNumberPage.getResult(), null);
                     }
                 }
-
-                LambdaQueryWrapper<TransportSgBaseNumber> lambdaQueryWrappera1 = new LambdaQueryWrapper();
-                lambdaQueryWrappera1.eq(TransportSgBaseNumber::getBaseYear, sgSyncStatuses.getSyncYear());
-                lambdaQueryWrappera1.eq(TransportSgBaseNumber::getBaseQuarter, sgSyncStatuses.getSyncQuarter());
-                baseNumberMapper.delete(lambdaQueryWrappera1.eq(TransportSgBaseNumber::getBaseCompyName,"上港集团"));
-                //所以企业数据合并成上港
+                //所以企业数据合并成上港的
                 LambdaQueryWrapper<TransportSgBaseNumber> lambdaQueryWrappera = new LambdaQueryWrapper();
                 lambdaQueryWrappera.eq(TransportSgBaseNumber::getBaseYear, sgSyncStatuses.getSyncYear());
                 lambdaQueryWrappera.eq(TransportSgBaseNumber::getBaseQuarter, sgSyncStatuses.getSyncQuarter());
+                sgBaseNumberLambdaQueryWrapper.ne(TransportSgBaseNumber::getBaseNotup,1);
                 IPage<TransportSgBaseNumber> baseNumberPages = baseNumberMapper.selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(count, pageSize), lambdaQueryWrappera);
                 if (baseNumberPages.getTotal() > pageSize) {
                     Long totalCount = baseNumberPage.getTotal();
                     Long totalPages = (totalCount + pageSize - 1) / pageSize;
-                    for (int i = count; i <= totalPages; i++) {
+                    for (int i = 1; i <= totalPages; i++) {
                         if (i == 1) {
                             baseNumberPages.getRecords().forEach(j -> {
                                 j.setBaseCompyName("上港集团");
@@ -343,12 +373,6 @@ public class SIPGDataTransportController extends CommonController  {
                     });
                     baseNumberService.saveOrUpdateBatch(baseNumberPages.getRecords());
                 }
-
-                LambdaQueryWrapper<TransportSgDwNzxBoat> lambdaQueryWrapper = new LambdaQueryWrapper();
-                lambdaQueryWrapper.eq(TransportSgDwNzxBoat::getTransUpdate, 1);
-                TransportSgDwNzxBoat sgDwNzxBoat = new TransportSgDwNzxBoat();
-                sgDwNzxBoat.setTransUpdate(0);
-                boatService.update(sgDwNzxBoat, lambdaQueryWrapper);
             }
 
         }else {
@@ -362,6 +386,9 @@ public class SIPGDataTransportController extends CommonController  {
         }
     }
 
+
+
+
     /**
      * 组装数据
      * @param sgBaseNumberList
@@ -441,6 +468,9 @@ public class SIPGDataTransportController extends CommonController  {
                 if (needSaveDatas!=null && needSaveDatas.size()>0)
                 {
                     System.out.println("===   存储数据:"+needSaveDatas.toString());
+                    needSaveDatas.forEach(i->{
+                        i.setUpdateTime(new Date());
+                    });
                     baseNumberService.saveOrUpdateBatch(needSaveDatas);
                     return needSaveDatas;
                 }
@@ -448,6 +478,7 @@ public class SIPGDataTransportController extends CommonController  {
             else {  //未查到
                 needSaveData.forEach(i->{
                     i.setBaseId(snowflakeConfig.snowflakeId());
+                    i.setUpdateTime(new Date());
                 });
                 System.out.println("===   存储数据:"+needSaveData.toString());
                 baseNumberService.saveOrUpdateBatch(needSaveData);

+ 45 - 0
ghjg-item-datashare-server/src/main/java/com/shanghaichengdi/ghjgitem/domain/TransportSgDwNzxAgent.java

@@ -3,10 +3,13 @@ package com.shanghaichengdi.ghjgitem.domain;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
+import java.util.Date;
+
 /**
  * <p>
  * 上港集团企业信息
@@ -36,4 +39,46 @@ public class TransportSgDwNzxAgent extends BaseEntity {
     private String nzaOutname;
 
 
+
+    @TableField("IS_DELETED")
+    private Integer isDeleted;
+
+    @TableField("COLUMN1")
+    private String column1;
+
+    @TableField("COLUMN2")
+    private String column2;
+
+    @TableField("COLUMN3")
+    private String column3;
+
+    @TableField("COLUMN4")
+    private String column4;
+
+    @TableField("COLUMN5")
+    private String column5;
+
+    @TableField("COLUMN6")
+    private String column6;
+
+    @TableField("COLUMN7")
+    private String column7;
+
+    @TableField("COLUMN8")
+    private String column8;
+
+    @TableField("CREATE_BY")
+    private String createBy;
+
+    @TableField("CREATE_TIME")
+    private Date createTime;
+
+    @TableField("UPDATE_BY")
+    private String updateBy;
+
+    @TableField("UPDATE_TIME")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+
 }

+ 40 - 0
ghjg-item-datashare-server/src/main/java/com/shanghaichengdi/ghjgitem/domain/TransportSgDwNzxContainers.java

@@ -183,4 +183,44 @@ public class TransportSgDwNzxContainers extends BaseEntity {
     private String nzcPortnm;
 
 
+
+    @TableField("IS_DELETED")
+    private Integer isDeleted;
+
+    @TableField("COLUMN1")
+    private String column1;
+
+    @TableField("COLUMN2")
+    private String column2;
+
+    @TableField("COLUMN3")
+    private String column3;
+
+    @TableField("COLUMN4")
+    private String column4;
+
+    @TableField("COLUMN5")
+    private String column5;
+
+    @TableField("COLUMN6")
+    private String column6;
+
+    @TableField("COLUMN7")
+    private String column7;
+
+    @TableField("COLUMN8")
+    private String column8;
+
+    @TableField("CREATE_BY")
+    private String createBy;
+
+    @TableField("CREATE_TIME")
+    private Date createTime;
+
+    @TableField("UPDATE_BY")
+    private String updateBy;
+
+    @TableField("UPDATE_TIME")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
 }

+ 8 - 4
ghjg-item-datashare-server/src/main/resources/mapper/TransportSgBaseNumberMapper.xml

@@ -12,19 +12,23 @@
         boat.NZX_AENDTM &gt;= #{startTime}
         and
         boat.NZX_AENDTM &lt;= #{endTime}
+        and con.NZC_DFG is null
+        and boat.NZX_DFG is null
         group by boat.nzx_agent,boat.nzx_vslcnname,boat.nzx_type,con.nzc_effg,con.NZC_CSIZECD
         order by boat.nzx_vslcnname,boat.nzx_type,con.nzc_effg,con.NZC_CSIZECD
     </select>
     <select id="getAllForCountDataForUpdate"
             resultType="com.shanghaichengdi.ghjgitem.domain.TransportSgBaseNumber">
-            select boat.nzx_agent baseCompyName,boat.nzx_vslcnname baseBoatName,boat.nzx_type baseType,con.NZC_CSIZECD column1,con.nzc_effg column2,count(con.nzc_pkid) column3 from
+        select boat.nzx_agent baseCompyName,boat.nzx_vslcnname baseBoatName,boat.nzx_type baseType,con.NZC_CSIZECD column1,con.nzc_effg column2,count(con.nzc_pkid) column3 from
         ghjg_port_manage.TRANSPORT_SG_DW_NZX_CONTAINERS con
         left join  ghjg_port_manage.TRANSPORT_SG_DW_NZX_BOAT boat on boat.nzx_sch_pkid=con.NZC_NZX_SCH_PKID
+        left join  GHJG_PORT_MANAGE.TRANSPORT_SG_BASE_NUMBER nu on boat.nzx_agent=nu.BASE_COMPY_NAME and boat.nzx_vslcnname=nu.base_Boat_Name and boat.nzx_type=nu.base_Type
         where
-        boat.NZX_AENDTM &gt;= #{startTime}
-        and
+                boat.NZX_AENDTM &gt;= #{startTime}
+         and con.NZC_DFG is null and
         boat.NZX_AENDTM &lt;= #{endTime}
-        and boat.trans_update=1
+        and  boat.NZX_DFG is null
+       and nu.BASE_NOTUP  is null
         group by boat.nzx_agent,boat.nzx_vslcnname,boat.nzx_type,con.nzc_effg,con.NZC_CSIZECD
         order by boat.nzx_vslcnname,boat.nzx_type,con.nzc_effg,con.NZC_CSIZECD
     </select>