|
@@ -945,299 +945,303 @@ public class AsyncTaskImportService {
|
|
|
Row row = hssfSheet.getRow(rowNum);
|
|
|
if(row != null){
|
|
|
|
|
|
- Cell accountnumberCell = row.getCell(0);//客户编码
|
|
|
- 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.equals("",accountnameCell.getStringCellValue())) {
|
|
|
- //throw new ServiceException(-900, "客户名称不能为空");
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (metercodeCell == null || StringUtils.isBlank(metercodeCell.getStringCellValue())) {
|
|
|
- //throw new ServiceException(-900, "水表编码不能为空");
|
|
|
- continue;
|
|
|
- }
|
|
|
- if(telephoneCell == null || StringUtils.isBlank(telephoneCell.getStringCellValue())){
|
|
|
- continue;
|
|
|
- }
|
|
|
+ try{
|
|
|
+ Cell accountnumberCell = row.getCell(0);//客户编码
|
|
|
+ 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.equals("",accountnameCell.getStringCellValue())) {
|
|
|
+ //throw new ServiceException(-900, "客户名称不能为空");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (metercodeCell == null || StringUtils.isBlank(metercodeCell.getStringCellValue())) {
|
|
|
+ //throw new ServiceException(-900, "水表编码不能为空");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(telephoneCell == null || StringUtils.isBlank(telephoneCell.getStringCellValue())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
/*if (meterelenoCell == null || StringUtils.isBlank(meterelenoCell.getStringCellValue())) {
|
|
|
throw new ServiceException(-900, "水表电子号不能为空");
|
|
|
}*/
|
|
|
- if(customergroupCell == null || StringUtils.isBlank(customergroupCell.getStringCellValue())){
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (calculatewayCell == null || StringUtils.isBlank(calculatewayCell.getStringCellValue())) {
|
|
|
- //throw new ServiceException(-900, "结算方式不能为空");
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (officeNameCell == null || StringUtils.isBlank(officeNameCell.getStringCellValue())) {
|
|
|
- //throw new ServiceException(-900, "机构不能为空");
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (propertyNameCell == null || StringUtils.isBlank(propertyNameCell.getStringCellValue())) {
|
|
|
- //throw new ServiceException(-900, "用水性质不能为空");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- String accountnumber = accountnumberCell.getStringCellValue().trim();
|
|
|
- String accountname = accountnameCell.getStringCellValue().trim();
|
|
|
- String metercode = metercodeCell.getStringCellValue().trim();
|
|
|
- String calculateway = calculatewayCell.getStringCellValue().trim();
|
|
|
- String officeName = officeNameCell.getStringCellValue().trim();
|
|
|
- String propertyName = propertyNameCell.getStringCellValue().trim();
|
|
|
- String fixedamount = fixedamountCell.getStringCellValue().trim();
|
|
|
- String idtype = idtypeCell.getStringCellValue().trim();
|
|
|
- String idcardno = idcardnoCell.getStringCellValue().trim();
|
|
|
- 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();
|
|
|
-
|
|
|
- //校验手机号是否正确
|
|
|
- if(StringUtils.isNotBlank(telephone)){
|
|
|
- String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
|
|
|
- if(telephone.length() != 11){
|
|
|
- failTime++ ;
|
|
|
- msg +="客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,";
|
|
|
- log.info("客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,");
|
|
|
- c_remark.setCellValue("客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,");
|
|
|
- continue;
|
|
|
- }else{
|
|
|
- Pattern p = Pattern.compile(regex);
|
|
|
- Matcher m = p.matcher(telephone);
|
|
|
- boolean isMatch = m.matches();
|
|
|
- if(!isMatch){
|
|
|
- failTime++ ;
|
|
|
- msg +="客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,";
|
|
|
- log.info("客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,");
|
|
|
- c_remark.setCellValue("客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,");
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //校验邮箱是否正确
|
|
|
- if(StringUtils.isNotBlank(email)){
|
|
|
- String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
|
|
|
- Pattern p = Pattern.compile(check);
|
|
|
- Matcher m = p.matcher(email);
|
|
|
- boolean isMatch = m.matches();
|
|
|
- if(!isMatch){
|
|
|
- failTime++ ;
|
|
|
- msg +="客户编码【"+accountnumber+"】您输入的邮箱格式有误,请重新输入,";
|
|
|
- log.info("客户编码【"+accountnumber+"】您输入的邮箱格式有误,请重新输入,");
|
|
|
- c_remark.setCellValue("客户编码【"+accountnumber+"】您输入的邮箱格式有误,请重新输入,");
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- PayBaseCustomerandmeterrela customer = new PayBaseCustomerandmeterrela();//实例化开户实体
|
|
|
- //根据客户编码寻找客户id
|
|
|
- PayBaseAccount accounts = payBaseCustomerandmeterrelaMapper.getAccountId(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber);
|
|
|
- //根据水表电子号寻找水表id
|
|
|
- PayBaseCustomerandmeterrela device = payBaseCustomerandmeterrelaMapper.getDeviceId(loginUser.getSiteId(),loginUser.getCustomerId(),metercode);
|
|
|
- //根据用水性质名称寻找用水性质id
|
|
|
- PayBaseCustomerandmeterrela property = payBaseCustomerandmeterrelaMapper.getWaterPropertyId(loginUser.getSiteId(),loginUser.getCustomerId(),propertyName);
|
|
|
- //根据机构名称寻找机构id
|
|
|
- Organization office = null;
|
|
|
- if(StringUtils.isNotBlank(officeName)){
|
|
|
- String[] number = officeName.split("/");
|
|
|
- office = payBaseCustomerandmeterrelaMapper.getOfficeId(loginUser.getSiteId(), number[0]);
|
|
|
- for (int i=1; i<number.length; i++){
|
|
|
- office = payBaseCustomerandmeterrelaMapper.getParentOfficeId(loginUser.getSiteId(),office.getId(),number[i]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(property == null){
|
|
|
- failTime++ ;
|
|
|
- msg +="客户编码【"+accountnumber+"】用水性质不能为空,";
|
|
|
- log.info("客户编码【"+accountnumber+"】用水性质不能为空,");
|
|
|
- c_remark.setCellValue("客户编码【"+accountnumber+"】用水性质不能为空,");
|
|
|
- continue;
|
|
|
- }
|
|
|
- if(office == null){
|
|
|
- failTime++ ;
|
|
|
- msg+="客户编码【"+accountnumber+"】机构信息有误,";
|
|
|
- log.info("客户编码【"+accountnumber+"】机构信息有误,");
|
|
|
- c_remark.setCellValue("客户编码【"+accountnumber+"】机构信息有误,");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(accounts == null){
|
|
|
- failTime++ ;
|
|
|
- msg +="【"+accountnumber+"】添加开户失败,客户信息有误,";
|
|
|
- log.info("【"+accountnumber+"】添加开户失败,客户信息有误,");
|
|
|
- c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,客户信息有误,");
|
|
|
- continue;
|
|
|
- //throw new ServiceException(ResultStatus.PAY_ADD_CUSTOMER_GETACCOUNT);
|
|
|
- }
|
|
|
- if(device == null){
|
|
|
- failTime++ ;
|
|
|
- msg += "【"+accountnumber+"】添加开户失败,水表信息有误,";
|
|
|
- log.info("【"+accountnumber+"】添加开户失败,水表信息有误,");
|
|
|
- c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,水表信息有误,");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //判断水表是否为待开户状态
|
|
|
- Integer state = payBaseCustomerandmeterrelaMapper.queryMeterState(loginUser.getCustomerId(),accounts.getId());
|
|
|
- state = state != null ? state : 0;
|
|
|
- if(state <=0){
|
|
|
- failTime++ ;
|
|
|
- msg +="【"+accountnumber+"】添加开户失败,该客户未验收,";
|
|
|
- log.info("【"+accountnumber+"】添加开户失败,该客户未验收,");
|
|
|
- c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户未验收,");
|
|
|
- continue;
|
|
|
- }
|
|
|
- Integer value = 0;
|
|
|
- customer.setVatno(vatno);
|
|
|
-
|
|
|
- PayBaseAccount saveAccount = payBaseAccountMapper.get(accounts.getId());
|
|
|
- if(idtype != null && idtype != ""){
|
|
|
- value = paySysDictService.getDictValue("证件类型",idtype,siteId,customerId);
|
|
|
- saveAccount.setIdtype(value);
|
|
|
- if(value != null && StringUtils.isBlank(idcardno)){
|
|
|
- failTime++ ;
|
|
|
- msg += "【"+accountnumber+"】添加开户失败,证件号码不能为空,";
|
|
|
- log.info("【"+accountnumber+"】添加开户失败,证件号码不能为空,");
|
|
|
- c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,证件号码不能为空,");
|
|
|
- continue;
|
|
|
- }
|
|
|
- saveAccount.setIdcardno(idcardno);
|
|
|
- }
|
|
|
-
|
|
|
- //判断客户是否销户后在开户
|
|
|
- PayBaseCustomerandmeterrela baseCustomer = payBaseCustomerandmeterrelaMapper.queryCancelInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
|
|
|
- if(baseCustomer != null && baseCustomer.getBusinessstate() != 1){
|
|
|
- //修改开户信息开户状态为已开户
|
|
|
- customer.setId(baseCustomer.getId());
|
|
|
- customer.setAccountId(accounts.getId());
|
|
|
- customer.setAccountnumber(accountnumber);
|
|
|
- customer.setAccountname(accountname);
|
|
|
- customer.setBusinessstate(1);//1已开户 2 销户 3未开户
|
|
|
- value = paySysDictService.getDictValue("结算方式",calculateway,siteId,customerId);
|
|
|
- customer.setCalculateway(value);//结算方式
|
|
|
- if(value != null && value == 2){
|
|
|
- if(StringUtils.isBlank(fixedamount)){
|
|
|
- failTime++ ;
|
|
|
- msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
|
|
|
- log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
|
|
|
- c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,结算水量不能为空,");
|
|
|
- continue;
|
|
|
- }
|
|
|
- customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
|
|
|
- }
|
|
|
- customer.setWatermeterId(device.getId());
|
|
|
- customer.setMetercode(metercode);
|
|
|
- customer.setOfficeId(BigInteger.valueOf(office.getId()));
|
|
|
- customer.setUpdateBy(loginUser.getId());
|
|
|
- customer.setUpdateDate(LocalDateTime.now());
|
|
|
- value = paySysDictService.getDictValue("住房类型",housetype,siteId,customerId);
|
|
|
- customer.setHousetype(value);//住房类型
|
|
|
- value = paySysDictService.getDictValue("开户分组",customerGroup,siteId,customerId);
|
|
|
- customer.setCustomergroup(value);//开户分组
|
|
|
-
|
|
|
- customer.setOpendate(LocalDateTime.now());
|
|
|
- customer.setWaterPropertyId(property.getWaterPropertyId());
|
|
|
- payBaseCustomerandmeterrelaMapper.update(customer);
|
|
|
- }else{
|
|
|
- //判断该客户编码跟水表档案是否已经存在开户信息中
|
|
|
- Integer count = payBaseCustomerandmeterrelaMapper.queryCustomerInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
|
|
|
- if(count != null && count >0){
|
|
|
-
|
|
|
- failTime++ ;
|
|
|
- msg += "【"+accountnumber+"】添加开户失败,该客户已存在,";
|
|
|
- log.info("【"+accountnumber+"】添加开户失败,该客户已存在,");
|
|
|
- c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- customer.setAccountId(accounts.getId());
|
|
|
- customer.setAccountname(accountname);
|
|
|
- customer.setAccountnumber(accountnumber);
|
|
|
- customer.setBusinessstate(1);//1已开户 2 销户 3未开户
|
|
|
- value = paySysDictService.getDictValue("结算方式",calculateway,siteId,customerId);
|
|
|
- customer.setCalculateway(value);//结算方式
|
|
|
- if(value != null && value == 2){
|
|
|
- if(StringUtils.isBlank(fixedamount)){
|
|
|
- failTime++ ;
|
|
|
- msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
|
|
|
- log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
|
|
|
- c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,结算水量不能为空,");
|
|
|
- continue;
|
|
|
- }
|
|
|
- customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
|
|
|
- }
|
|
|
- customer.setWatermeterId(device.getId());
|
|
|
- customer.setMetercode(metercode);
|
|
|
- customer.setOfficeId(BigInteger.valueOf(office.getId()));
|
|
|
- customer.setUpdateBy(loginUser.getId());
|
|
|
- customer.setUpdateDate(LocalDateTime.now());
|
|
|
- customer.setCreateBy(loginUser.getId());
|
|
|
- customer.setCreateDate(LocalDateTime.now());
|
|
|
- customer.setDelFlag("0");
|
|
|
- customer.setRemarks("");
|
|
|
- customer.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
|
|
|
- customer.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
- value = paySysDictService.getDictValue("住房类型",housetype,siteId,customerId);
|
|
|
- customer.setHousetype(value);//住房类型
|
|
|
- value = paySysDictService.getDictValue("开户分组",customerGroup,siteId,customerId);
|
|
|
- customer.setCustomergroup(value);//开户分组
|
|
|
- customer.setOpendate(LocalDateTime.now());
|
|
|
- customer.setWaterPropertyId(property.getWaterPropertyId());
|
|
|
- customerList.add(customer);
|
|
|
- }
|
|
|
-
|
|
|
- //计算可用水量
|
|
|
- if(property.getWaterPropertyId() != null){
|
|
|
- Boolean flag = payBaseCustomerandmeterrelaService.UpdateAccountInfo(property.getWaterPropertyId(),accounts.getId(),null,loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
+ if(customergroupCell == null || StringUtils.isBlank(customergroupCell.getStringCellValue())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (calculatewayCell == null || StringUtils.isBlank(calculatewayCell.getStringCellValue())) {
|
|
|
+ //throw new ServiceException(-900, "结算方式不能为空");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (officeNameCell == null || StringUtils.isBlank(officeNameCell.getStringCellValue())) {
|
|
|
+ //throw new ServiceException(-900, "机构不能为空");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (propertyNameCell == null || StringUtils.isBlank(propertyNameCell.getStringCellValue())) {
|
|
|
+ //throw new ServiceException(-900, "用水性质不能为空");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String accountnumber = accountnumberCell.getStringCellValue().trim();
|
|
|
+ String accountname = accountnameCell.getStringCellValue().trim();
|
|
|
+ String metercode = metercodeCell.getStringCellValue().trim();
|
|
|
+ String calculateway = calculatewayCell.getStringCellValue().trim();
|
|
|
+ String officeName = officeNameCell.getStringCellValue().trim();
|
|
|
+ String propertyName = propertyNameCell.getStringCellValue().trim();
|
|
|
+ String fixedamount = fixedamountCell.getStringCellValue().trim();
|
|
|
+ String idtype = idtypeCell.getStringCellValue().trim();
|
|
|
+ String idcardno = idcardnoCell.getStringCellValue().trim();
|
|
|
+ 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();
|
|
|
+
|
|
|
+ //校验手机号是否正确
|
|
|
+ if(StringUtils.isNotBlank(telephone)){
|
|
|
+ String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
|
|
|
+ if(telephone.length() != 11){
|
|
|
+ failTime++ ;
|
|
|
+ msg +="客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,";
|
|
|
+ log.info("客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,");
|
|
|
+ c_remark.setCellValue("客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,");
|
|
|
+ continue;
|
|
|
+ }else{
|
|
|
+ Pattern p = Pattern.compile(regex);
|
|
|
+ Matcher m = p.matcher(telephone);
|
|
|
+ boolean isMatch = m.matches();
|
|
|
+ if(!isMatch){
|
|
|
+ failTime++ ;
|
|
|
+ msg +="客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,";
|
|
|
+ log.info("客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,");
|
|
|
+ c_remark.setCellValue("客户编码【"+accountnumber+"】您输入的手机号格式有误,请重新输入,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验邮箱是否正确
|
|
|
+ if(StringUtils.isNotBlank(email)){
|
|
|
+ String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
|
|
|
+ Pattern p = Pattern.compile(check);
|
|
|
+ Matcher m = p.matcher(email);
|
|
|
+ boolean isMatch = m.matches();
|
|
|
+ if(!isMatch){
|
|
|
+ failTime++ ;
|
|
|
+ msg +="客户编码【"+accountnumber+"】您输入的邮箱格式有误,请重新输入,";
|
|
|
+ log.info("客户编码【"+accountnumber+"】您输入的邮箱格式有误,请重新输入,");
|
|
|
+ c_remark.setCellValue("客户编码【"+accountnumber+"】您输入的邮箱格式有误,请重新输入,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PayBaseCustomerandmeterrela customer = new PayBaseCustomerandmeterrela();//实例化开户实体
|
|
|
+ //根据客户编码寻找客户id
|
|
|
+ PayBaseAccount accounts = payBaseCustomerandmeterrelaMapper.getAccountId(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber);
|
|
|
+ //根据水表电子号寻找水表id
|
|
|
+ PayBaseCustomerandmeterrela device = payBaseCustomerandmeterrelaMapper.getDeviceId(loginUser.getSiteId(),loginUser.getCustomerId(),metercode);
|
|
|
+ //根据用水性质名称寻找用水性质id
|
|
|
+ PayBaseCustomerandmeterrela property = payBaseCustomerandmeterrelaMapper.getWaterPropertyId(loginUser.getSiteId(),loginUser.getCustomerId(),propertyName);
|
|
|
+ //根据机构名称寻找机构id
|
|
|
+ Organization office = null;
|
|
|
+ if(StringUtils.isNotBlank(officeName)){
|
|
|
+ String[] number = officeName.split("/");
|
|
|
+ office = payBaseCustomerandmeterrelaMapper.getOfficeId(loginUser.getSiteId(), number[0]);
|
|
|
+ for (int i=1; i<number.length; i++){
|
|
|
+ office = payBaseCustomerandmeterrelaMapper.getParentOfficeId(loginUser.getSiteId(),office.getId(),number[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(property == null){
|
|
|
+ failTime++ ;
|
|
|
+ msg +="客户编码【"+accountnumber+"】用水性质不能为空,";
|
|
|
+ log.info("客户编码【"+accountnumber+"】用水性质不能为空,");
|
|
|
+ c_remark.setCellValue("客户编码【"+accountnumber+"】用水性质不能为空,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(office == null){
|
|
|
+ failTime++ ;
|
|
|
+ msg+="客户编码【"+accountnumber+"】机构信息有误,";
|
|
|
+ log.info("客户编码【"+accountnumber+"】机构信息有误,");
|
|
|
+ c_remark.setCellValue("客户编码【"+accountnumber+"】机构信息有误,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(accounts == null){
|
|
|
+ failTime++ ;
|
|
|
+ msg +="【"+accountnumber+"】添加开户失败,客户信息有误,";
|
|
|
+ log.info("【"+accountnumber+"】添加开户失败,客户信息有误,");
|
|
|
+ c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,客户信息有误,");
|
|
|
+ continue;
|
|
|
+ //throw new ServiceException(ResultStatus.PAY_ADD_CUSTOMER_GETACCOUNT);
|
|
|
+ }
|
|
|
+ if(device == null){
|
|
|
+ failTime++ ;
|
|
|
+ msg += "【"+accountnumber+"】添加开户失败,水表信息有误,";
|
|
|
+ log.info("【"+accountnumber+"】添加开户失败,水表信息有误,");
|
|
|
+ c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,水表信息有误,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断水表是否为待开户状态
|
|
|
+ Integer state = payBaseCustomerandmeterrelaMapper.queryMeterState(loginUser.getCustomerId(),accounts.getId());
|
|
|
+ state = state != null ? state : 0;
|
|
|
+ if(state <=0){
|
|
|
+ failTime++ ;
|
|
|
+ msg +="【"+accountnumber+"】添加开户失败,该客户未验收,";
|
|
|
+ log.info("【"+accountnumber+"】添加开户失败,该客户未验收,");
|
|
|
+ c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户未验收,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Integer value = 0;
|
|
|
+ customer.setVatno(vatno);
|
|
|
+
|
|
|
+ PayBaseAccount saveAccount = payBaseAccountMapper.get(accounts.getId());
|
|
|
+ if(idtype != null && idtype != ""){
|
|
|
+ value = paySysDictService.getDictValue("证件类型",idtype,siteId,customerId);
|
|
|
+ saveAccount.setIdtype(value);
|
|
|
+ if(value != null && StringUtils.isBlank(idcardno)){
|
|
|
+ failTime++ ;
|
|
|
+ msg += "【"+accountnumber+"】添加开户失败,证件号码不能为空,";
|
|
|
+ log.info("【"+accountnumber+"】添加开户失败,证件号码不能为空,");
|
|
|
+ c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,证件号码不能为空,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ saveAccount.setIdcardno(idcardno);
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断客户是否销户后在开户
|
|
|
+ PayBaseCustomerandmeterrela baseCustomer = payBaseCustomerandmeterrelaMapper.queryCancelInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
|
|
|
+ if(baseCustomer != null && baseCustomer.getBusinessstate() != 1){
|
|
|
+ //修改开户信息开户状态为已开户
|
|
|
+ customer.setId(baseCustomer.getId());
|
|
|
+ customer.setAccountId(accounts.getId());
|
|
|
+ customer.setAccountnumber(accountnumber);
|
|
|
+ customer.setAccountname(accountname);
|
|
|
+ customer.setBusinessstate(1);//1已开户 2 销户 3未开户
|
|
|
+ value = paySysDictService.getDictValue("结算方式",calculateway,siteId,customerId);
|
|
|
+ customer.setCalculateway(value);//结算方式
|
|
|
+ if(value != null && value == 2){
|
|
|
+ if(StringUtils.isBlank(fixedamount)){
|
|
|
+ failTime++ ;
|
|
|
+ msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
|
|
|
+ log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
|
|
|
+ c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,结算水量不能为空,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
|
|
|
+ }
|
|
|
+ customer.setWatermeterId(device.getId());
|
|
|
+ customer.setMetercode(metercode);
|
|
|
+ customer.setOfficeId(BigInteger.valueOf(office.getId()));
|
|
|
+ customer.setUpdateBy(loginUser.getId());
|
|
|
+ customer.setUpdateDate(LocalDateTime.now());
|
|
|
+ value = paySysDictService.getDictValue("住房类型",housetype,siteId,customerId);
|
|
|
+ customer.setHousetype(value);//住房类型
|
|
|
+ value = paySysDictService.getDictValue("开户分组",customerGroup,siteId,customerId);
|
|
|
+ customer.setCustomergroup(value);//开户分组
|
|
|
+
|
|
|
+ customer.setOpendate(LocalDateTime.now());
|
|
|
+ customer.setWaterPropertyId(property.getWaterPropertyId());
|
|
|
+ payBaseCustomerandmeterrelaMapper.update(customer);
|
|
|
+ }else{
|
|
|
+ //判断该客户编码跟水表档案是否已经存在开户信息中
|
|
|
+ Integer count = payBaseCustomerandmeterrelaMapper.queryCustomerInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
|
|
|
+ if(count != null && count >0){
|
|
|
+
|
|
|
+ failTime++ ;
|
|
|
+ msg += "【"+accountnumber+"】添加开户失败,该客户已存在,";
|
|
|
+ log.info("【"+accountnumber+"】添加开户失败,该客户已存在,");
|
|
|
+ c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ customer.setAccountId(accounts.getId());
|
|
|
+ customer.setAccountname(accountname);
|
|
|
+ customer.setAccountnumber(accountnumber);
|
|
|
+ customer.setBusinessstate(1);//1已开户 2 销户 3未开户
|
|
|
+ value = paySysDictService.getDictValue("结算方式",calculateway,siteId,customerId);
|
|
|
+ customer.setCalculateway(value);//结算方式
|
|
|
+ if(value != null && value == 2){
|
|
|
+ if(StringUtils.isBlank(fixedamount)){
|
|
|
+ failTime++ ;
|
|
|
+ msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
|
|
|
+ log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
|
|
|
+ c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,结算水量不能为空,");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
|
|
|
+ }
|
|
|
+ customer.setWatermeterId(device.getId());
|
|
|
+ customer.setMetercode(metercode);
|
|
|
+ customer.setOfficeId(BigInteger.valueOf(office.getId()));
|
|
|
+ customer.setUpdateBy(loginUser.getId());
|
|
|
+ customer.setUpdateDate(LocalDateTime.now());
|
|
|
+ customer.setCreateBy(loginUser.getId());
|
|
|
+ customer.setCreateDate(LocalDateTime.now());
|
|
|
+ customer.setDelFlag("0");
|
|
|
+ customer.setRemarks("");
|
|
|
+ customer.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
|
|
|
+ customer.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
+ value = paySysDictService.getDictValue("住房类型",housetype,siteId,customerId);
|
|
|
+ customer.setHousetype(value);//住房类型
|
|
|
+ value = paySysDictService.getDictValue("开户分组",customerGroup,siteId,customerId);
|
|
|
+ customer.setCustomergroup(value);//开户分组
|
|
|
+ customer.setOpendate(LocalDateTime.now());
|
|
|
+ customer.setWaterPropertyId(property.getWaterPropertyId());
|
|
|
+ customerList.add(customer);
|
|
|
+ }
|
|
|
+
|
|
|
+ //计算可用水量
|
|
|
+ if(property.getWaterPropertyId() != null){
|
|
|
+ Boolean flag = payBaseCustomerandmeterrelaService.UpdateAccountInfo(property.getWaterPropertyId(),accounts.getId(),null,loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
/*if (!flag){
|
|
|
throw new ServiceException(ResultStatus.PAY_ADD_CUSTOMER_UPDATEAMOUNT);
|
|
|
}*/
|
|
|
- }
|
|
|
-
|
|
|
- //修改客户信息
|
|
|
- saveAccount.setName(accountnameCell.getStringCellValue());
|
|
|
- saveAccount.setTelephone(telephone);
|
|
|
- saveAccount.setMobilephone(telephone);
|
|
|
- saveAccount.setId(accounts.getId());
|
|
|
- saveAccount.setSiteId(siteId);
|
|
|
- saveAccount.setCustomerId(customerId);
|
|
|
- saveAccount.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
|
|
|
- saveAccount.setUpdateDate(LocalDateTime.now());
|
|
|
- saveAccount.setEmail(email);
|
|
|
- payBaseAccountService.update(saveAccount);
|
|
|
-
|
|
|
- //修改预存账户名称
|
|
|
- PayRechargeaccountDto rechargeaccountDto = new PayRechargeaccountDto();
|
|
|
- rechargeaccountDto.setAccountId(accounts.getId());
|
|
|
- rechargeaccountDto.setOfficeId(BigInteger.valueOf(office.getId()));
|
|
|
- rechargeaccountDto.setBusinessstate(1);
|
|
|
- rechargeaccountDto.setAccountname(accountname);
|
|
|
- rechargeaccountDto.setSiteId(siteId);
|
|
|
- rechargeaccountDto.setCustomerId(customerId);
|
|
|
- payRechargeaccountMapper.update(rechargeaccountDto);
|
|
|
- //修改水表安装信息为已开户
|
|
|
- payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(2,loginUser.getUpdateBy(),LocalDateTime.now(),device.getId());
|
|
|
- successTime ++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改客户信息
|
|
|
+ saveAccount.setName(accountnameCell.getStringCellValue());
|
|
|
+ saveAccount.setTelephone(telephone);
|
|
|
+ saveAccount.setMobilephone(telephone);
|
|
|
+ saveAccount.setId(accounts.getId());
|
|
|
+ saveAccount.setSiteId(siteId);
|
|
|
+ saveAccount.setCustomerId(customerId);
|
|
|
+ saveAccount.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
|
|
|
+ saveAccount.setUpdateDate(LocalDateTime.now());
|
|
|
+ saveAccount.setEmail(email);
|
|
|
+ payBaseAccountService.update(saveAccount);
|
|
|
+
|
|
|
+ //修改预存账户名称
|
|
|
+ PayRechargeaccountDto rechargeaccountDto = new PayRechargeaccountDto();
|
|
|
+ rechargeaccountDto.setAccountId(accounts.getId());
|
|
|
+ rechargeaccountDto.setOfficeId(BigInteger.valueOf(office.getId()));
|
|
|
+ rechargeaccountDto.setBusinessstate(1);
|
|
|
+ rechargeaccountDto.setAccountname(accountname);
|
|
|
+ rechargeaccountDto.setSiteId(siteId);
|
|
|
+ rechargeaccountDto.setCustomerId(customerId);
|
|
|
+ payRechargeaccountMapper.update(rechargeaccountDto);
|
|
|
+ //修改水表安装信息为已开户
|
|
|
+ payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(2,loginUser.getUpdateBy(),LocalDateTime.now(),device.getId());
|
|
|
+ successTime ++;
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
log.info("开始循环为空的行上移");
|