소스 검색

已使用小区不能删除

zhoujiangyuan 4 년 전
부모
커밋
4982f14fff

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayBaseAccountMapper.java

@@ -53,5 +53,9 @@ public interface PayBaseAccountMapper {
 
     void updateAccountName(@Param("type")Integer type,@Param("accountname")String accountname,@Param("accountId")BigInteger accountId);
 
+    //获取未同步的水表信息
     List<SynAccountInfo> getSynAccountInfo( @Param("createDate")String createDate);
+
+    //查询小区是否已使用
+    int findCommunityCount(@Param("communityId") Integer communityId);
 }

+ 9 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CommunityServiceImpl.java

@@ -7,6 +7,7 @@ import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.dao.AreaMapper;
 import com.bz.smart_city.dao.CommunityMapper;
+import com.bz.smart_city.dao.pay.PayBaseAccountMapper;
 import com.bz.smart_city.dto.BuildingSelectDto;
 import com.bz.smart_city.dto.CommunityDto;
 import com.bz.smart_city.dto.LoginUser;
@@ -35,6 +36,9 @@ public class CommunityServiceImpl implements CommunityService{
     @Resource
     private AreaMapper areaMapper;
 
+    @Resource
+    private PayBaseAccountMapper payBaseAccountMapper;
+
     @Override
     public int insert(Community community){
         community.setCreateBy("system");
@@ -167,6 +171,11 @@ public class CommunityServiceImpl implements CommunityService{
     public void deleteCommunity(Integer communityId) {
         log.info("Begin DeleteCommunity CommunityId" + communityId);
 
+        int result = payBaseAccountMapper.findCommunityCount(communityId);
+        if(result > 0){
+            throw new ServiceException(-900,"该小区已经使用,不能删除");
+        }
+
         Community community = new Community();
         community.setId(communityId);
         community.setStatus(0);

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/DeviceSyncServiceImpl.java

@@ -71,7 +71,7 @@ public class DeviceSyncServiceImpl implements DeviceSyncService, InitializingBea
         if(!exists){
 
             //每隔X分钟一次
-            String cron = "0 */1 * * * ?";
+            String cron = "0 */2 * * * ?";
             log.info("水表安装信息同步"+cron);
             entity.setCronExpression(cron);
             entity.setJobClassName(DeviceSyncJob.class.getName());

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PaySyncDataServiceImpl.java

@@ -181,6 +181,9 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
             code =String.format("%03d",Integer.valueOf(community.getCode()));
         }
 
+        //将小区置空,因为抄表系统小区与本系统中小区不一定要同
+        installPlanInput.setCommunityId(null);
+
         //取当前小区最大客户编号
         int maxAccountNumber = payBaseAccountService.getMaxAccountNumber(code);
 

+ 2 - 2
smart-city-platform/src/main/resources/mapper/DeviceMapper.xml

@@ -87,8 +87,8 @@
             <if test="devices.deviceType != null"> device_model = #{devices.deviceType,jdbcType=INTEGER},</if>
             <if test="devices.locDesc != null">loc_desc = #{devices.locDesc,jdbcType=VARCHAR},</if>
             <if test="devices.waterMeterNo != null">water_meter_no = #{devices.waterMeterNo,jdbcType=VARCHAR},</if>
-            <if test="devices.dateCreate != null">date_create = #{devices.dateCreate,jdbcType=VARCHAR},</if>
-            <if test="devices.dateUpdate != null">date_update = #{devices.dateUpdate,jdbcType=VARCHAR},</if>
+            <if test="devices.dateCreate != null and devices.dateCreate != ''">date_create = #{devices.dateCreate,jdbcType=VARCHAR},</if>
+            <if test="devices.dateUpdate != null and devices.dateUpdate != ''">date_update = #{devices.dateUpdate,jdbcType=VARCHAR},</if>
             <if test="devices.status != null">status = #{devices.status,jdbcType=INTEGER},</if>
             <if test="devices.currStatus != null">curr_status = #{devices.currStatus,jdbcType=INTEGER},</if>
             <if test="devices.initialData != null">new_meter_start = #{devices.initialData,jdbcType=VARCHAR},</if>

+ 4 - 0
smart-city-platform/src/main/resources/mapper/pay/PayBaseAccountMapper.xml

@@ -535,4 +535,8 @@
             where DATE_FORMAT( c.create_date, "%Y%m%d" ) = #{createDate}
         </if>
     </select>
+
+    <select id="findCommunityCount" resultType="integer">
+        select COUNT(1) from pay_base_account where SUBSTR(accountnumber,1,3)=(select code from sc_community where id = #{communityId})
+    </select>
 </mapper>