Browse Source

1批量导入修改

Xiaojh 4 years ago
parent
commit
21dfb2698d

+ 6 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dao/OrganizationMapper.java

@@ -27,6 +27,11 @@ public interface OrganizationMapper {
     
     List<Organization> findListByIds(@Param("orgIds")Integer[] orgIds);
 
-
     List<OrganizationDto> findListByCustomer(@Param("siteId")Integer siteId,@Param("customerId") Integer customerId);
+
+    List<OrganizationDto> fingByOrganizationOne(@Param("siteId")Integer siteId,@Param("customerId") Integer customerId);
+
+    List<OrganizationDto> findListLikeOrgin(@Param("id")Integer id,@Param("siteId")Integer siteId,@Param("customerId") Integer customerId);
+
+    String findOrginName(@Param("id")String id,@Param("siteId")Integer siteId,@Param("customerId") Integer customerId);
 }

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

@@ -921,6 +921,8 @@ public class AsyncTaskImportService {
         StringBuffer messageContent = new StringBuffer();
         messageContent.append(record.getImportFileName());
         String msg = "";
+        BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
+        BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
         if(file != null){
             try{
                 InputStream inputStream = new FileInputStream(record.getImportFilePath());
@@ -942,27 +944,26 @@ public class AsyncTaskImportService {
                         if(row != null){
 
                             Cell accountnumberCell = row.getCell(0);//客户编码
-                            Cell accountnameCell = row.getCell(1);//客户名称
-                            Cell telephoneCell = row.getCell(2);//手机号码
-                            Cell metercodeCell = row.getCell(3);//水表档案号
-                            Cell calculatewayCell = row.getCell(4);//结算方式
-                            Cell fixedamountCell = row.getCell(5);//固定量
-                            Cell customergroupCell = row.getCell(6);//开户分组
-                            Cell officeNameCell = row.getCell(7);//机构名称
-                            Cell propertyNameCell = row.getCell(8);//用水性质
-                            Cell idtypeCell = row.getCell(9);//证件类型
-                            Cell idcardnoCell = row.getCell(10);//证件号码
-                            Cell housetypeCell = row.getCell(11);//住房类型
-                            Cell vatnoCell = row.getCell(12);//公司税号
-                            Cell emailCell = row.getCell(13);//邮箱
-                            //Cell c_remark = row.getCell(11);//备注
-
-
-                            if (accountnumberCell == null || StringUtils.isBlank(accountnumberCell.getStringCellValue())) {
+                            Cell metercodeCell = row.getCell(2);//水表档案号
+                            Cell propertyNameCell = row.getCell(4);//用水性质
+                            Cell calculatewayCell = row.getCell(6);//结算方式
+                            Cell fixedamountCell = row.getCell(8);//固定量
+                            Cell accountnameCell = row.getCell(9);//客户名称
+                            Cell idtypeCell = row.getCell(10);//证件类型
+                            Cell idcardnoCell = row.getCell(12);//证件号码
+                            Cell telephoneCell = row.getCell(13);//手机号码
+                            Cell officeNameCell = row.getCell(14);//机构名称
+                            Cell housetypeCell = row.getCell(16);//住房类型
+                            Cell customergroupCell = row.getCell(18);//开户分组
+                            Cell vatnoCell = row.getCell(20);//公司税号
+                            Cell emailCell = row.getCell(21);//电子邮箱
+                            Cell c_remark = row.getCell(22);//备注
+
+                            if (accountnumberCell == null || StringUtils.equals("",accountnumberCell.getStringCellValue())) {
                                 //throw new ServiceException(-900, "客户编码不能为空");
                                 continue;
                             }
-                            if (accountnameCell == null || StringUtils.isBlank(accountnameCell.getStringCellValue())) {
+                            if (accountnameCell == null || StringUtils.equals("",accountnameCell.getStringCellValue())) {
                                 //throw new ServiceException(-900, "客户名称不能为空");
                                 continue;
                             }
@@ -991,9 +992,6 @@ public class AsyncTaskImportService {
                                 //throw new ServiceException(-900, "用水性质不能为空");
                                 continue;
                             }
-                            if(customergroupCell == null || StringUtils.isBlank(customergroupCell.getStringCellValue())){
-                                continue;
-                            }
 
                             String accountnumber = accountnumberCell.getStringCellValue().trim();
                             String accountname = accountnameCell.getStringCellValue().trim();
@@ -1007,6 +1005,9 @@ public class AsyncTaskImportService {
                             String telephone = telephoneCell.getStringCellValue().trim();
                             String vatno = vatnoCell.getStringCellValue().trim();
                             String email = emailCell.getStringCellValue().trim();
+                            String housetype = housetypeCell.getStringCellValue().trim();
+                            String customerGroup = customergroupCell.getStringCellValue().trim();
+
                             PayBaseCustomerandmeterrela customer =  new PayBaseCustomerandmeterrela();//实例化开户实体
                             //根据客户编码寻找客户id
                             PayBaseAccount accounts = payBaseCustomerandmeterrelaMapper.getAccountId(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber);
@@ -1026,8 +1027,8 @@ public class AsyncTaskImportService {
 
                             if(property == null){
                                 failTime++ ;
-                                msg +="客户编码【"+accountnumber+"】住房类型不能为空,";
-                                log.info("客户编码【"+accountnumber+"】住房类型不能为空,");
+                                msg +="客户编码【"+accountnumber+"】用水性质不能为空,";
+                                log.info("客户编码【"+accountnumber+"】用水性质不能为空,");
                                 //c_remark.setCellValue("客户编码【"+accountnumber+"】住房类型不能为空,");
                                 continue;
                             }
@@ -1077,7 +1078,7 @@ public class AsyncTaskImportService {
                                 customer.setAccountnumber(accountnumber);
                                 customer.setAccountname(accountname);
                                 customer.setBusinessstate(1);//1已开户 2 销户 3未开户
-                                value = paySysDictService.getDictValue("结算方式",calculateway,new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                value = paySysDictService.getDictValue("结算方式",calculateway,siteId,customerId);
                                 customer.setCalculateway(value);//结算方式
                                 if(value != null && value == 2){
                                     if(StringUtils.isBlank(fixedamount)){
@@ -1094,9 +1095,9 @@ public class AsyncTaskImportService {
                                 customer.setOfficeId(BigInteger.valueOf(office.getId()));
                                 customer.setUpdateBy(loginUser.getId());
                                 customer.setUpdateDate(LocalDateTime.now());
-                                value = paySysDictService.getDictValue("住房类型",housetypeCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                value = paySysDictService.getDictValue("住房类型",housetype,siteId,customerId);
                                 customer.setHousetype(value);//住房类型
-                                value = paySysDictService.getDictValue("开户分组",customergroupCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                value = paySysDictService.getDictValue("开户分组",customerGroup,siteId,customerId);
                                 customer.setCustomergroup(value);//开户分组
 
                                 customer.setOpendate(LocalDateTime.now());
@@ -1118,7 +1119,7 @@ public class AsyncTaskImportService {
                                 customer.setAccountname(accountname);
                                 customer.setAccountnumber(accountnumber);
                                 customer.setBusinessstate(1);//1已开户 2 销户 3未开户
-                                value = paySysDictService.getDictValue("结算方式",calculateway,new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                value = paySysDictService.getDictValue("结算方式",calculateway,siteId,customerId);
                                 customer.setCalculateway(value);//结算方式
                                 if(value != null && value == 2){
                                     if(StringUtils.isBlank(fixedamount)){
@@ -1141,9 +1142,9 @@ public class AsyncTaskImportService {
                                 customer.setRemarks("");
                                 customer.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
                                 customer.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
-                                value = paySysDictService.getDictValue("住房类型",housetypeCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                value = paySysDictService.getDictValue("住房类型",housetype,siteId,customerId);
                                 customer.setHousetype(value);//住房类型
-                                value = paySysDictService.getDictValue("开户分组",customergroupCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                value = paySysDictService.getDictValue("开户分组",customerGroup,siteId,customerId);
                                 customer.setCustomergroup(value);//开户分组
                                 customer.setOpendate(LocalDateTime.now());
                                 customer.setWaterPropertyId(property.getWaterPropertyId());
@@ -1162,7 +1163,7 @@ public class AsyncTaskImportService {
                             PayBaseAccount saveAccount  = payBaseAccountMapper.get(accounts.getId());
                             saveAccount.setName(accountnameCell.getStringCellValue());
                             if(idtype != null && idtype != ""){
-                                value = paySysDictService.getDictValue("证件类型",idtype,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+                                value = paySysDictService.getDictValue("证件类型",idtype,siteId,customerId);
                                 saveAccount.setIdtype(value);
                                 if(value != null && StringUtils.isBlank(idcardno)){
                                     failTime++ ;
@@ -1176,8 +1177,8 @@ public class AsyncTaskImportService {
                             saveAccount.setTelephone(telephone);
                             saveAccount.setMobilephone(telephone);
                             saveAccount.setId(accounts.getId());
-                            saveAccount.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
-                            saveAccount.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+                            saveAccount.setSiteId(siteId);
+                            saveAccount.setCustomerId(customerId);
                             saveAccount.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
                             saveAccount.setUpdateDate(LocalDateTime.now());
                             saveAccount.setEmail(email);
@@ -1189,8 +1190,8 @@ public class AsyncTaskImportService {
                             rechargeaccountDto.setOfficeId(BigInteger.valueOf(office.getId()));
                             rechargeaccountDto.setBusinessstate(1);
                             rechargeaccountDto.setAccountname(accountname);
-                            rechargeaccountDto.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
-                            rechargeaccountDto.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+                            rechargeaccountDto.setSiteId(siteId);
+                            rechargeaccountDto.setCustomerId(customerId);
                             payRechargeaccountMapper.update(rechargeaccountDto);
                             //修改水表安装信息为已开户
                             payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(2,loginUser.getUpdateBy(),LocalDateTime.now(),device.getId());

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

@@ -742,7 +742,36 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
             //4.查找证件类型集合
             List<PaySysDictSelectDto> cardList  = paySysDictMapper.getAll(null,null,"证件类型",siteId,customerId);
             //5.查找机构类型集合
-            List<OrganizationDto> organizationList = organizationMapper.findListForCustomer(loginUser.getCustomerId());
+            List<OrganizationDto> list = new ArrayList<OrganizationDto>();
+            //先获取第一节点数据
+            List<OrganizationDto> organizationList = organizationMapper.fingByOrganizationOne(loginUser.getSiteId(),loginUser.getCustomerId());
+            String name = "";
+            for(int i=0; i<organizationList.size(); i++){
+                Integer id = organizationList.get(i).getId();
+                List<OrganizationDto> likeList = organizationMapper.findListLikeOrgin(id,loginUser.getSiteId(),loginUser.getCustomerId());
+                for(int j=0; j<likeList.size(); j++){
+                    String collections = likeList.get(j).getCollections();
+                    String[] coll = collections.split(",");
+                    String orgNames = "";
+                    for(int k=0; k<coll.length; k++){
+                        if(StringUtils.isNotBlank(coll[k])){
+                            String orgId = coll[k];
+                            String orgName = organizationMapper.findOrginName(orgId,loginUser.getSiteId(),loginUser.getCustomerId());
+                            orgNames += orgName +"/";
+                        }
+                    }
+                    orgNames = orgNames.substring(0,orgNames.length()-1);
+                    name = orgNames+"/"+likeList.get(j).getName();
+                    if(StringUtils.isNotBlank(name)){
+                        OrganizationDto dto = new OrganizationDto();
+                        dto.setName(name);
+                        list.add(dto);
+                        name = "";
+                    }
+                    orgNames = "";
+                }
+            }
+            organizationList.addAll(list);
             //6.查找住房类型集合
             List<PaySysDictSelectDto> houseList  = paySysDictMapper.getAll(null,null,"住房类型",siteId,customerId);
             //7.查找开户分组集合

BIN
smart-city-platform/src/main/resources/excel/batchOpenAccountTemplate.xlsx


+ 32 - 0
smart-city-platform/src/main/resources/mapper/OrganizationMapper.xml

@@ -213,5 +213,37 @@
         and id in
         <foreach collection="orgIds" item="orgId" open="(" separator="," close=")">#{orgId}</foreach>
     </select>
+    <select id="fingByOrganizationOne" resultType="com.bz.smart_city.dto.OrganizationDto">
+        select <include refid="Base_Column_List"/>
+        from sc_organization
+        where status = 1 and parent_id = '0'
+        <if test="customerId != null"> and customer_id = #{customerId} </if>
+        <if test="siteId != null">and site_id =#{siteId}</if>
+        order by create_date desc
+    </select>
+
+    <select id="findListLikeOrgin" resultType="com.bz.smart_city.dto.OrganizationDto">
+        select <include refid="Base_Column_List"/>
+        from sc_organization
+        where status = 1
+        <if test="customerId != null"> and customer_id = #{customerId} </if>
+        <if test="siteId != null">and site_id =#{siteId}</if>
+        <if test="id != null">
+            and collections like concat('%',#{id},'%')
+        </if>
+        order by create_date desc
+    </select>
+
+
+    <select id="findOrginName" resultType="java.lang.String">
+        select name as "name"
+        from sc_organization
+        where status = 1
+        <if test="customerId != null"> and customer_id = #{customerId} </if>
+        <if test="siteId != null">and site_id =#{siteId}</if>
+        <if test="id != null">
+            and id=#{id}
+        </if>
+    </select>
 </mapper>