Browse Source

修改用户开户标志

zhoujiangyuan 4 years ago
parent
commit
a0d9aad6e6

+ 34 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/system/PersonTypeDefController.java

@@ -73,4 +73,38 @@ public class PersonTypeDefController {
         return new AjaxMessage(ResultStatus.OK);
     }
 
+    @PostMapping("add")
+    @ApiOperation(value = "添加人员类型")
+    public AjaxMessage add(
+            @ApiParam(value = "人员类型", required = true) @RequestBody(required = true) @Validated PersonTypeDefDto personTypeDefDto
+    ) {
+        int count = personTypeDefService.insert(personTypeDefDto);
+        if(0 != count) {
+            return new AjaxMessage<>(-997, "该人员类型名称已存在!", null);
+        } else {
+            return new AjaxMessage(ResultStatus.OK);
+        }
+    }
+
+    @DeleteMapping("delete")
+    @ApiOperation(value = "删除人员类型")
+    public AjaxMessage delete(
+            @ApiParam(value = "人员类型id", required = true) @RequestParam int id
+    ) {
+        int result = personTypeDefService.delete(id);
+        return new AjaxMessage(ResultStatus.OK, result);
+    }
+
+    @PostMapping("edit")
+    @ApiOperation(value = "修改人员类型")
+    public AjaxMessage edit(
+            @ApiParam(value = "人员类型", required = true) @RequestBody(required = true) @Validated PersonTypeDefDto personTypeDefDto) {
+        int count = personTypeDefService.updateByPrimaryKeySelective(personTypeDefDto);
+        if(0 != count) {
+            return new AjaxMessage<>(-997, "该人员类型名称已存在!", null);
+        } else {
+            return new AjaxMessage(ResultStatus.OK);
+        }
+    }
+
 }

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/PersonTypeChannelMapper.java

@@ -17,4 +17,5 @@ public interface PersonTypeChannelMapper {
 
     int updateByPrimaryKeySelective(@Param("personTypeChannel") PersonTypeChannel personTypeChannel);
 
+    int isBindChannel(@Param("personTypeDefId") int personTypeDefId);
 }

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/PersonTypeDimensionMapper.java

@@ -12,4 +12,6 @@ public interface PersonTypeDimensionMapper {
     int updateStatus(@Param("personTypeDefId") int personTypeDefId, @Param("dimensionIdList") int[] dimensionIdList, @Param("status")int status);
 
     List<PersonTypeDimension> queryDimensionListById(@Param("personTypeDefId") int personTypeDefId);
+
+    int insertAllDimension(@Param("personTypeDefId") int personTypeDefId);
 }

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/archives/PayBaseCustomerandmeterrelaMapper.java

@@ -95,4 +95,6 @@ public interface PayBaseCustomerandmeterrelaMapper {
     public Organization getParentOfficeId( @Param("siteId")Integer siteId,@Param("id")Integer id,@Param("name") String name);
 
     public PayBaseCustomerandmeterrela findAccountByAccountNumber(@Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("accountnumber")String accountnumber);
+
+    void updateMeterInstallOpen(@Param("isAccepted")Integer isAccepted, @Param("updateBy")String updateBy,@Param("date") LocalDateTime date, @Param("id") BigInteger id);
 }

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/PersonTypeDefService.java

@@ -20,4 +20,8 @@ public interface PersonTypeDefService{
     int channelBindPersonType(int channelId, int[] insertPersonTypeId, int[] delPersonTypeIds, int[] updPersonTypeIds);
 
     int queryByName(String name, int id);
+
+    int insert(PersonTypeDefDto personTypeDefDto);
+
+    int delete(int id);
 }

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

@@ -100,4 +100,31 @@ public class PersonTypeDefServiceImpl implements PersonTypeDefService{
         return personTypeDefMapper.queryByName(name, id);
     }
 
+    @Override
+    public int insert(PersonTypeDefDto personTypeDefDto){
+        int count = queryByName(personTypeDefDto.getName(), 0);
+        if(0 == count) {
+            personTypeDefDto.setStatus(1);
+            personTypeDefMapper.insert(personTypeDefDto);
+            int[] dimensionIds = personTypeDefDto.getDimensionList();
+            int personTypeDefId = personTypeDefDto.getId();
+            personTypeDimensionMapper.insertAllDimension(personTypeDefId);
+            if(0 != dimensionIds.length) {
+                personTypeDimensionMapper.updateStatus(personTypeDefId, dimensionIds, 1);
+            }
+        }
+        return count;
+    }
+
+    @Override
+    public int delete(int id) {
+        int isBind = personTypeChannelMapper.isBindChannel(id);
+        if(0 == isBind) {
+            PersonTypeDefDto personTypeDefDto = new PersonTypeDefDto();
+            personTypeDefDto.setId(id);
+            personTypeDefDto.setStatus(0);
+            personTypeDefMapper.updateByPrimaryKeySelective(personTypeDefDto);
+        }
+        return isBind;
+    }
 }

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

@@ -190,6 +190,7 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
         //楼栋
         if (installPlanInput.getInstallPlanDataList() != null && installPlanInput.getInstallPlanDataList().size() > 0) {
             List<PayBaseAccountDto> accountLists = newArrayList();
+            List<Device> deviceList = new ArrayList<>();
 
             for (InstallPlanDataDTO installPlanBuilding : installPlanInput.getInstallPlanDataList()) {
                 //单元
@@ -234,6 +235,17 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
                                         accountLists.add(payBaseAccountDto);
 
                                         installPlanDoor.setFileNo(strAccountNumber+"01");
+
+                                        //生成水表信息
+                                        long deviceId = idWorker.nextId();
+                                        Device device = new Device();
+                                        device.setId(deviceId);
+                                        device.setMetercode(payBaseAccountDto.getAccountnumber()+"01");
+                                        device.setAccountId(payBaseAccountDto.getId());
+                                        device.setSiteId(loginUser.getSiteId());
+                                        device.setCustomerId(loginUser.getCustomerId());
+                                        device.setCurrStatus(0);
+                                        deviceList.add(device);
                                     }
                                 }
                             }
@@ -254,18 +266,6 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
                     payBaseAccountService.batchInsert(accountLists, code);
 
                     //生成水表信息(sc_device表)
-                    List<Device> deviceList = new ArrayList<>();
-                    for (PayBaseAccountDto  payBaseAccount : accountLists){
-                        long deviceId = idWorker.nextId();
-                        Device device = new Device();
-                        device.setId(deviceId);
-                        device.setMetercode(payBaseAccount.getAccountnumber()+"01");
-                        device.setAccountId(payBaseAccount.getId());
-                        device.setSiteId(loginUser.getSiteId());
-                        device.setCustomerId(loginUser.getCustomerId());
-                        device.setCurrStatus(0);
-                        deviceList.add(device);
-                    }
                     deviceMapper.insertList(deviceList);
 
                     return ajaxMessage;

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java

@@ -406,6 +406,8 @@ public class AsyncTaskImportService {
                                rechargeaccountDto.setSiteId(siteId);
                                rechargeaccountDto.setCustomerId(customerId);
                                payRechargeaccountMapper.update(rechargeaccountDto);
+                               //修改水表安装信息为已开户
+                               payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(2,loginUser.getUpdateBy(),LocalDateTime.now(),device.getId());
                                successTime ++;
                            }catch (Exception e){
                                e.printStackTrace();

+ 11 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java

@@ -313,6 +313,9 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
         rechargeaccountDto.setCustomerId(new BigInteger(String.valueOf(loginUser.getCustomerId())));
         payRechargeaccountMapper.update(rechargeaccountDto);
 
+        //修改水表安装信息为已开户
+        payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(2,loginUser.getUpdateBy(),LocalDateTime.now(),device.getId());
+
         if (customerList.size() > 0) {
             int reslut = payBaseCustomerandmeterrelaMapper.insertList(customerList);
 
@@ -429,6 +432,9 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
         rechargeaccountDto.setCustomerId(new BigInteger(String.valueOf(loginUser.getCustomerId())));
         payRechargeaccountMapper.update(rechargeaccountDto);
 
+        //修改水表安装信息为已开户
+        payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(2,loginUser.getUpdateBy(),LocalDateTime.now(),device.getId());
+
         if (customerList.size() > 0) {
             int reslut = payBaseCustomerandmeterrelaMapper.insertList(customerList);
 
@@ -1018,6 +1024,8 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
                             rechargeaccountDto.setSiteId(new BigInteger(String.valueOf(loginUser.getSiteId())));
                             rechargeaccountDto.setCustomerId(new BigInteger(String.valueOf(loginUser.getCustomerId())));
                             payRechargeaccountMapper.update(rechargeaccountDto);
+                            //修改水表安装信息为已开户
+                            payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(2,loginUser.getUpdateBy(),LocalDateTime.now(),device.getId());
                         }
                     }
 
@@ -1101,6 +1109,9 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
             //修改预存账户为销户
             result = payBaseCustomerandmeterrelaMapper.updateRechargeAccountState(2,loginUser.getId(),new Date(),loginUser.getSiteId(),loginUser.getCustomerId(),customerList.get(0).getAccountId());//开户状态:1已开户 2销户 3未开户
 
+            //修改水表安装信息为待开户
+            payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(1,loginUser.getUpdateBy(),LocalDateTime.now(),customerList.get(0).getWatermeterId());
+
             //修改客户状态为销户
             payBaseCustomerandmeterrelaMapper.updateAccountState(3,loginUser.getId(),new Date(),loginUser.getSiteId(),loginUser.getCustomerId(),customerList.get(0).getAccountId());//客户状态状态:1正常 2欠费 3销户
         }

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

@@ -91,7 +91,7 @@
             <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>
+            <if test="devices.initialData != null">new_meter_start = #{devices.initialData,jdbcType=VARCHAR}</if>
         </set>
         where metercode = #{devices.fileNo,jdbcType=VARCHAR}
     </update>

+ 5 - 0
smart-city-platform/src/main/resources/mapper/PersonTypeChannelMapper.xml

@@ -133,5 +133,10 @@
         WHERE id = #{personTypeChannel.id,jdbcType=INTEGER}
     </update>
 
+    <!--查询人员类型是否关联场景-->
+    <select id="isBindChannel" resultType="int">
+        select count(1) from sc_person_type_channel
+        where person_type_def_id = #{personTypeDefId} and status = 1
+    </select>
 </mapper>
 

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

@@ -46,5 +46,9 @@
     <select id="queryDimensionListById" resultMap="BaseResultMap">
         select dimension_id from sc_person_type_dimension where person_type_def_id = #{personTypeDefId} and status = 1
     </select>
+
+    <insert id="insertAllDimension">
+        insert INTO sc_person_type_dimension(dimension_id, person_type_def_id, status) SELECT id, #{personTypeDefId}, 0 from sc_dimension
+    </insert>
 </mapper>
 

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

@@ -491,7 +491,7 @@
             )
         </if>
         <if test="state != null and state != '' ">
-            and IFNULL(scinstall.curr_status,0) = #{state,jdbcType=INTEGER}
+            and IFNULL(scd.curr_status,0) = #{state,jdbcType=INTEGER}
         </if>
         <if test="programItemList != null and programItemList.size() > 0">
             and ( ppr.office_id is null