|
@@ -5,6 +5,7 @@ import com.bz.smart_city.commom.util.FileUtil;
|
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
|
import com.bz.smart_city.commom.util.Util;
|
|
|
import com.bz.smart_city.dao.pay.PayBaseAccountMapper;
|
|
|
+import com.bz.smart_city.dao.pay.PayControlRuleMapper;
|
|
|
import com.bz.smart_city.dao.pay.PayRechargeaccountMapper;
|
|
|
import com.bz.smart_city.dao.pay.archives.PayBaseCustomerandmeterrelaMapper;
|
|
|
import com.bz.smart_city.dto.LoginUser;
|
|
@@ -13,6 +14,8 @@ import com.bz.smart_city.entity.Import;
|
|
|
import com.bz.smart_city.entity.Message;
|
|
|
import com.bz.smart_city.entity.Organization;
|
|
|
import com.bz.smart_city.entity.pay.PayBaseAccount;
|
|
|
+import com.bz.smart_city.entity.pay.PayControlRule;
|
|
|
+import com.bz.smart_city.entity.pay.PayControlValve;
|
|
|
import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
|
|
|
import com.bz.smart_city.excel.resolver.InstallPlanResolverExcelTemplate;
|
|
|
import com.bz.smart_city.service.ImportService;
|
|
@@ -67,6 +70,8 @@ public class AsyncTaskImportService {
|
|
|
private PayBaseAccountService payBaseAccountService;
|
|
|
@Autowired
|
|
|
private InstallPlanResolverExcelTemplate installPlanResolverExcelTemplate;
|
|
|
+ @Resource
|
|
|
+ private PayControlRuleMapper payControlRuleMapper;
|
|
|
|
|
|
@Value("${files.path}")
|
|
|
private String filesPath;
|
|
@@ -107,6 +112,7 @@ public class AsyncTaskImportService {
|
|
|
|
|
|
FormulaEvaluator evaluator = hssfWorkbook.getCreationHelper().createFormulaEvaluator();
|
|
|
List<PayBaseCustomerandmeterrela> customerList = newArrayList();
|
|
|
+ List<PayControlValve> valveList = newArrayList();//阀控记录
|
|
|
// 循环工作表Sheet
|
|
|
for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
|
|
|
|
|
@@ -131,8 +137,9 @@ public class AsyncTaskImportService {
|
|
|
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 vatnoCell = row.getCell(19);//公司税号
|
|
|
+ Cell emailCell = row.getCell(20);//电子邮箱
|
|
|
+ Cell controlCell = row.getCell(21);//阀控规则
|
|
|
Cell c_remark = row.getCell(22);//备注
|
|
|
|
|
|
if (accountnumberCell == null || StringUtils.equals("",accountnumberCell.getStringCellValue())) {
|
|
@@ -183,6 +190,7 @@ public class AsyncTaskImportService {
|
|
|
String email = emailCell.getStringCellValue().trim();
|
|
|
String housetype = housetypeCell.getStringCellValue().trim();
|
|
|
String customerGroup = customergroupCell.getStringCellValue().trim();
|
|
|
+ String contollName = controlCell.getStringCellValue().trim();
|
|
|
|
|
|
//去重
|
|
|
if(!number_maps.containsKey(accountnumber)){
|
|
@@ -234,12 +242,15 @@ public class AsyncTaskImportService {
|
|
|
}
|
|
|
|
|
|
PayBaseCustomerandmeterrela customer = new PayBaseCustomerandmeterrela();//实例化开户实体
|
|
|
+ PayControlValve valve = new PayControlValve();//实例化阀控实体
|
|
|
//根据客户编码寻找客户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
|
|
|
+ List<PayControlRule> contollList = payControlRuleMapper.findList(null,contollName,customerId);
|
|
|
//根据机构名称寻找机构id
|
|
|
Organization office = null;
|
|
|
if(StringUtils.isNotBlank(officeName)){
|
|
@@ -329,7 +340,9 @@ public class AsyncTaskImportService {
|
|
|
customer.setHousetype(value);//住房类型
|
|
|
value = paySysDictService.getDictValue("开户分组",customerGroup,siteId,customerId);
|
|
|
customer.setCustomergroup(value);//开户分组
|
|
|
-
|
|
|
+ customer.setValveRuleName(contollName);
|
|
|
+ customer.setValveRuleName(contollName);
|
|
|
+ customer.setValveRuleId(contollList != null && contollList.size() >0 ? String.valueOf(contollList.get(0).getId()) : "");
|
|
|
customer.setOpendate(LocalDateTime.now());
|
|
|
customer.setWaterPropertyId(property.getWaterPropertyId());
|
|
|
payBaseCustomerandmeterrelaMapper.update(customer);
|
|
@@ -378,9 +391,17 @@ public class AsyncTaskImportService {
|
|
|
customer.setCustomergroup(value);//开户分组
|
|
|
customer.setOpendate(LocalDateTime.now());
|
|
|
customer.setWaterPropertyId(property.getWaterPropertyId());
|
|
|
+ customer.setValveRuleName(contollName);
|
|
|
+ customer.setValveRuleId(contollList != null && contollList.size() >0 ? String.valueOf(contollList.get(0).getId()) : "");
|
|
|
customerList.add(customer);
|
|
|
}
|
|
|
|
|
|
+ //插入阀控记录
|
|
|
+ valve.setDeviceId(device.getId());
|
|
|
+ valve.setControlState(1);
|
|
|
+ valve.setControlTime(LocalDateTime.now());
|
|
|
+ valveList.add(valve);
|
|
|
+
|
|
|
//计算可用水量
|
|
|
if(property.getWaterPropertyId() != null){
|
|
|
Boolean flag = payBaseCustomerandmeterrelaService.UpdateAccountInfo(property.getWaterPropertyId(),accounts.getId(),null,loginUser.getSiteId(),loginUser.getCustomerId());
|
|
@@ -433,6 +454,10 @@ public class AsyncTaskImportService {
|
|
|
int reslut = payBaseCustomerandmeterrelaMapper.insertList(customerList);
|
|
|
log.info("insert reslut:" + reslut);
|
|
|
}
|
|
|
+ if(valveList.size() >0){
|
|
|
+ int reslut = payBaseCustomerandmeterrelaMapper.insertValveList(valveList);
|
|
|
+ log.info("insert valveResult:" + reslut);
|
|
|
+ }
|
|
|
log.info("结束循环为空的行上移");
|
|
|
messageContent.append("导入完成,");
|
|
|
messageContent.append("导入成功");
|