Redeem hace 1 año
padre
commit
98bebc5891

+ 8 - 3
src/main/java/com/steerinfo/dil/controller/RmsDirectlySentCityController.java

@@ -40,7 +40,7 @@ public class RmsDirectlySentCityController extends BaseRESTfulController {
         if (mapValue==null){
             mapValue=new HashMap<>();
         }
-        if (con != null && !"null".equals(con)){
+        if (con != null && !"null".equals(con) && !"".equals(con)){
             mapValue.put("con",con);
         }
         PageHelper.startPage(pageNum, pageSize);
@@ -56,8 +56,13 @@ public class RmsDirectlySentCityController extends BaseRESTfulController {
     @ApiOperation("新增直发城市维护")
     @PostMapping("insertDirectlySentCityInfo")
     public RESTfulResult insertDirectlySentCityInfo(@RequestBody Map<String,Object> map) {
-        int i = rmsDirectlySentCityService.insertDirectlySentCityInfo(map);
-        return success();
+        try {
+            int i = rmsDirectlySentCityService.insertDirectlySentCityInfo(map);
+            return success(i);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return failed(e.getMessage());
+        }
     }
 
     @ApiOperation("删除直发城市维护")

+ 10 - 0
src/main/java/com/steerinfo/dil/mapper/RmsDirectlySentCityMapper.java

@@ -3,6 +3,8 @@ package com.steerinfo.dil.mapper;
 import com.steerinfo.dil.model.RmsDirectlySentCity;
 import com.steerinfo.framework.mapper.IBaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Options;
+import org.apache.ibatis.annotations.Select;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -14,5 +16,13 @@ public interface RmsDirectlySentCityMapper extends IBaseMapper<RmsDirectlySentCi
 
     List<Map<String, Object>> getDirectlySentCity(Map<String, Object> mapValue);
 
+    @Options(flushCache = Options.FlushCachePolicy.TRUE)
+    @Select("SELECT SEQ_DIRECTLY.nextval FROM dual")
     BigDecimal getMaxId();
+
+    List<BigDecimal> selectAddressId(Map<String, Object> infoMap);
+
+
+
+
 }

+ 16 - 3
src/main/java/com/steerinfo/dil/service/impl/RmsDirectlySentCityServiceImpl.java

@@ -7,9 +7,11 @@ import com.steerinfo.dil.service.IRmsDirectlySentCityService;
 import com.steerinfo.dil.service.IRmsDriverCapacityService;
 import com.steerinfo.dil.util.DataChange;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import javax.xml.crypto.Data;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -25,17 +27,28 @@ public class RmsDirectlySentCityServiceImpl implements IRmsDirectlySentCityServi
         return rmsDirectlySentCityMapper.getDirectlySentCity(mapValue);
     }
 
-    public int insertDirectlySentCityInfo(Map<String, Object> map) {
+    @Transactional(rollbackFor = Exception.class)
+    public int insertDirectlySentCityInfo(Map<String, Object> map) throws Exception {
         List<Map<String,Object>> mapList = (List<Map<String, Object>>) map.get("mapList");
         List<RmsDirectlySentCity> rmsDirectlySentCities = new ArrayList<>();
         for(Map<String,Object> infoMap : mapList) {
+            //判断省市县是否在我们系统
+            List<BigDecimal> addressIds = rmsDirectlySentCityMapper.selectAddressId(infoMap);
+            if (addressIds.size() == 0 || addressIds.get(0) == null) {
+                //continue;
+                throw new Exception(infoMap.get("provinceName") + "" + infoMap.get("districtName") + ""+ infoMap.get("townName") + "该地址不存在");
+            }
             RmsDirectlySentCity rmsDirectlySentCity = new RmsDirectlySentCity();
             rmsDirectlySentCity.setPrimaryKeyId(rmsDirectlySentCityMapper.getMaxId());
             rmsDirectlySentCity.setDirectlySentName(infoMap.get("directlySentName") + "");
             rmsDirectlySentCity.setProvinceCity(infoMap.get("provinceName").toString());
             rmsDirectlySentCity.setDistrictCity(infoMap.get("districtName").toString());
-            rmsDirectlySentCity.setTownCity(infoMap.get("townName") + "");
-            rmsDirectlySentCity.setPlace(infoMap.get("place") + "");
+            if (infoMap.containsKey("townName")) {
+                rmsDirectlySentCity.setTownCity(infoMap.get("townName") + "");
+            }
+            if (infoMap.containsKey("place")) {
+                rmsDirectlySentCity.setPlace(infoMap.get("place") + "");
+            }
             rmsDirectlySentCity.setCarrierId(DataChange.dataToBigDecimal(infoMap.get("carrierId")));
             rmsDirectlySentCity.setAlternateFields1(map.get("userName") + "");
             rmsDirectlySentCities.add(rmsDirectlySentCity);

+ 8 - 2
src/main/resources/com/steerinfo/dil/mapper/RmsDirectlySentCityMapper.xml

@@ -511,8 +511,14 @@
       WHERE RDSC.DIRECTLY_SENT_NAME = #{con}
     </if>
   </select>
-  <select id="getMaxId" resultType="java.math.BigDecimal">
-    SELECT NVL(MAX(PRIMARY_KEY_ID),0) + 1 FROM RMS_DIRECTLY_SENT_CITY
+
+  <select id="selectAddressId" resultType="java.math.BigDecimal">
+    SELECT ADDRESS_ID FROM RMS_RECEIVE_ADDRESS RRA
+    WHERE RRA.ADDRESS_PROVINCE = #{provinceName}
+    AND RRA.ADDRESS_DISTRICT = #{districtName}
+    <if test="townName != null and townName != ''">
+      AND RRA.ADDRESS_TOWN = #{townName}
+    </if>
   </select>
 
 </mapper>