PtlTaxSourceServiceImpl.java 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. package com.ydtech.modules.protocol.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5. import com.ydtech.constants.enums.InsuranceRisk;
  6. import com.ydtech.exception.SystemException;
  7. import com.ydtech.modules.admin.model.dto.SysUserLinkPtlAgreementDto;
  8. import com.ydtech.modules.base.controller.BaseController;
  9. import com.ydtech.modules.ins.model.vo.KindInfoVo;
  10. import com.ydtech.modules.ins.model.vo.RiskInfoVo;
  11. import com.ydtech.modules.order.entity.BasePageResult;
  12. import com.ydtech.modules.order.entity.InsOrders;
  13. import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
  14. import com.ydtech.modules.order.service.InsOrdersService;
  15. import com.ydtech.modules.protocol.constants.DispatchTypeConstants;
  16. import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
  17. import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
  18. import com.ydtech.modules.protocol.entity.dto.PtlTaxSourceNewDto;
  19. import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
  20. import com.ydtech.modules.protocol.entity.po.PtlAreaLicense;
  21. import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNew;
  22. import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNewHistory;
  23. import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNewRecord;
  24. import com.ydtech.modules.protocol.entity.vo.PtlTaxSourceNewAddDeptIdsVo;
  25. import com.ydtech.modules.protocol.entity.vo.PtlTaxSourceNewAddVo;
  26. import com.ydtech.modules.protocol.entity.vo.PtlTaxSourceNewSaveVo;
  27. import com.ydtech.modules.protocol.entity.vo.PtlTaxSourceNewVo;
  28. import com.ydtech.modules.protocol.service.*;
  29. import com.ydtech.modules.protocol.utils.RulesMergeStrUtils;
  30. import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesAttr;
  31. import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesAttrLink;
  32. import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesAttrLinkHistory;
  33. import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesDictLabal;
  34. import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesAttrLinkHistoryService;
  35. import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesAttrLinkService;
  36. import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesAttrService;
  37. import com.ydtech.utils.idgen.IdGenerate;
  38. import org.apache.commons.lang3.StringUtils;
  39. import org.springframework.beans.BeanUtils;
  40. import org.springframework.beans.factory.annotation.Autowired;
  41. import org.springframework.stereotype.Service;
  42. import org.springframework.transaction.annotation.Transactional;
  43. import java.time.LocalDateTime;
  44. import java.util.ArrayList;
  45. import java.util.Date;
  46. import java.util.List;
  47. import java.util.stream.Collectors;
  48. import static com.ydtech.modules.order.utils.InsuranceLog.logger;
  49. @Service
  50. public class PtlTaxSourceServiceImpl extends ServiceImpl<PtlTaxSourceNewMapper, PtlTaxSourceNew> implements PtlTaxSourceNewService {
  51. @Autowired
  52. private ITaxSourceExcludeService taxSourceExcludeService;
  53. @Autowired
  54. private PtlTaxSourceNewMapper ptlTaxSourceNewMapper;
  55. @Autowired
  56. private PtlTaxSourceNewHistoryService ptlTaxSourceNewHistoryService;
  57. @Autowired
  58. private PtlAgreementDispatchRulesAttrService ptlAgreementDispatchRulesAttrService;
  59. @Autowired
  60. private PtlAgreementDispatchRulesAttrLinkService ptlAgreementDispatchRulesAttrLinkService;
  61. @Autowired
  62. private PtlAgreementDispatchRulesAttrLinkHistoryService ptlAgreementDispatchRulesAttrLinkHistoryService;
  63. @Autowired
  64. private PtlAreaLicenseService ptlAreaLicenseService;
  65. @Autowired
  66. private PtlTaxSourceNewRecordService ptlTaxSourceNewRecordService;
  67. @Autowired
  68. private InsOrdersService insOrdersService;
  69. /**
  70. * @version
  71. * @author: hxl
  72. * @Date: 2024/5/22 15:44
  73. * @Description: 协议调度分页
  74. */
  75. @Override
  76. public BasePageResult<PtlTaxSourceNewVo> queryPage(PtlTaxSourceNewDto ptlTaxSourceNewDto) {
  77. Page<SysUserLinkPtlAgreementDto> page = new Page<>(ptlTaxSourceNewDto.getPageNum(),
  78. ptlTaxSourceNewDto.getPageSize());
  79. Page<PtlTaxSourceNewVo> ptlTaxSourceNewVoBasePageResult = ptlTaxSourceNewMapper.queryPage(page, ptlTaxSourceNewDto);
  80. return new BasePageResult<>(ptlTaxSourceNewDto.getPageNum(), page.getSize(), ptlTaxSourceNewVoBasePageResult.getTotal(), page.getPages(),
  81. ptlTaxSourceNewVoBasePageResult.getRecords());
  82. }
  83. /**
  84. * @version
  85. * @author: hxl
  86. * @Date: 2024/5/22 15:44
  87. * @Description: 协议调度保存或修改
  88. */
  89. @Transactional
  90. @Override
  91. public void add(PtlTaxSourceNewAddVo ptlTaxSourceNewAddVo) {
  92. //添加
  93. // int count= ptlTaxSourceNewMapper.findListByParams(ptlTaxSourceNewAddVo);
  94. // if(count>0){
  95. // throw new SystemException("该协议已经存在,不允许再次添加!!");
  96. // }
  97. //查询定义的规则表
  98. List<PtlAgreementDispatchRulesAttr> dispatchRulesAttrList = ptlAgreementDispatchRulesAttrService.getDispatchRulesAttrList();
  99. List<PtlAgreementDispatchRulesAttrLink> attrLinks = ptlTaxSourceNewAddVo.getAttrLinks();
  100. String content = RulesMergeStrUtils.getRulesMergeStr(attrLinks, dispatchRulesAttrList);
  101. if(content==null || "".equals(content)){
  102. throw new SystemException("规则列表未填写,请添加规则!!");
  103. }
  104. //判断有没有默认值
  105. PtlTaxSourceNew ptlTaxSourceNewDefault= ptlTaxSourceNewMapper.findDefaultAttrLinkByInsCompanyId(ptlTaxSourceNewAddVo.getInsCompanyId());
  106. //新增
  107. PtlTaxSourceNew ptlTaxSourceNew=new PtlTaxSourceNew();
  108. ptlTaxSourceNew =ptlTaxSourceNew.getNewEntity(ptlTaxSourceNewAddVo,ptlTaxSourceNew);
  109. ptlTaxSourceNew.setDispatchContent(content);
  110. ptlTaxSourceNew.setCreateTime(new Date());
  111. ptlTaxSourceNew.setCreateUser(BaseController.getUser().getId());
  112. if(ptlTaxSourceNewDefault==null){
  113. if("0".equals(ptlTaxSourceNew.getDefaultFlag())){
  114. //设置数据为默认
  115. throw new SystemException("该保险公司不存在默认数据,请设置为默认");
  116. }
  117. }else{
  118. //当前数据为默认的话,将之前的数据设置为非默认
  119. if("1".equals(ptlTaxSourceNew.getDefaultFlag()) ){
  120. //将旧数据设置数据为非默认
  121. ptlTaxSourceNewDefault.setDefaultFlag("0");
  122. ptlTaxSourceNewMapper.updateById(ptlTaxSourceNewDefault);
  123. }
  124. }
  125. ptlTaxSourceNewMapper.insert(ptlTaxSourceNew);
  126. //生成批次ID
  127. String uuid = IdGenerate.nextId();
  128. //插入规则表
  129. List<PtlAgreementDispatchRulesAttrLink> allAttrLink = new ArrayList<>();
  130. List<PtlAgreementDispatchRulesAttrLinkHistory> dispatchAttrLinkHistories = new ArrayList<>();
  131. PtlTaxSourceNew finalPtlTaxSourceNew = ptlTaxSourceNew;
  132. attrLinks.forEach(x -> {
  133. PtlAgreementDispatchRulesAttrLinkHistory dispatchAttrLinkHistory = new PtlAgreementDispatchRulesAttrLinkHistory();
  134. //处理中文逗号
  135. if (x.getMin() != null && x.getMin().contains(",")) {
  136. x.setMin(x.getMin().replace(",", ","));
  137. }
  138. PtlAgreementDispatchRulesAttrLink finalX = x;
  139. PtlAgreementDispatchRulesAttr ptlAgreementDispatchRulesAttr = dispatchRulesAttrList.stream().filter(y -> y.getAttrCode().equals(finalX.getAttrCode())).findFirst().orElse(new PtlAgreementDispatchRulesAttr());
  140. //单独处理车牌号
  141. if ("LicenseNo".equals(x.getAttrCode()) && (x.getMin() != null && !x.getMin().equals(""))) {
  142. x.setOperator("0");
  143. x.setId("0");
  144. x.setRulesId(finalPtlTaxSourceNew.getId()+"");
  145. allAttrLink.add(x);
  146. BeanUtils.copyProperties(x, dispatchAttrLinkHistory);
  147. //设置产品费用因子历史记录
  148. dispatchAttrLinkHistory.setId(null);
  149. dispatchAttrLinkHistory.setBatch(uuid);
  150. dispatchAttrLinkHistory.setOperatorType("add");
  151. dispatchAttrLinkHistory.setModifier(BaseController.getUser().getId());
  152. dispatchAttrLinkHistory.setOperatorTime(LocalDateTime.now());
  153. dispatchAttrLinkHistories.add(dispatchAttrLinkHistory);
  154. } else {
  155. if (ptlAgreementDispatchRulesAttr.getAttrType().equals("radio")|| "checkbox".equals(ptlAgreementDispatchRulesAttr.getAttrType())) {
  156. if ( null != x.getMin() && !"".equals(x.getMin())) {
  157. x.setId("0");
  158. x.setRulesId(finalPtlTaxSourceNew.getId()+"");
  159. x=getAttrLink(x);
  160. allAttrLink.add(x);
  161. BeanUtils.copyProperties(x, dispatchAttrLinkHistory);
  162. //设置产品费用因子历史记录
  163. dispatchAttrLinkHistory.setId(null);
  164. dispatchAttrLinkHistory.setBatch(uuid);
  165. dispatchAttrLinkHistory.setOperatorType("add");
  166. dispatchAttrLinkHistory.setModifier(BaseController.getUser().getId());
  167. dispatchAttrLinkHistory.setOperatorTime(LocalDateTime.now());
  168. dispatchAttrLinkHistory=getAttrLinkHistory(dispatchAttrLinkHistory);
  169. dispatchAttrLinkHistories.add(dispatchAttrLinkHistory);
  170. }
  171. }else if( ( null != x.getMin() && !"0".equals(x.getMin()) && null != x.getOperator() && !"".equals(x.getOperator() )) || ( null != x.getMax() && !"0".equals(x.getMax()) && null != x.getOperator() && !"".equals(x.getOperator()) ) ) {
  172. x.setId("0");
  173. x.setRulesId(finalPtlTaxSourceNew.getId()+"");
  174. x=getAttrLink(x);
  175. allAttrLink.add(x);
  176. BeanUtils.copyProperties(x, dispatchAttrLinkHistory);
  177. //设置产品费用因子历史记录
  178. dispatchAttrLinkHistory.setId(null);
  179. dispatchAttrLinkHistory.setBatch(uuid);
  180. dispatchAttrLinkHistory.setOperatorType("add");
  181. dispatchAttrLinkHistory.setModifier(BaseController.getUser().getId());
  182. dispatchAttrLinkHistory.setOperatorTime(LocalDateTime.now());
  183. dispatchAttrLinkHistory=getAttrLinkHistory(dispatchAttrLinkHistory);
  184. dispatchAttrLinkHistories.add(dispatchAttrLinkHistory);
  185. }
  186. }
  187. });
  188. //插入调度历史记录表
  189. //历史记录表
  190. PtlTaxSourceNewHistory ptlTaxSourceNewHistory=new PtlTaxSourceNewHistory();
  191. BeanUtils.copyProperties(ptlTaxSourceNew, ptlTaxSourceNewHistory);
  192. ptlTaxSourceNewHistory.setId(null);
  193. ptlTaxSourceNewHistory.setBatchId(uuid);
  194. ptlTaxSourceNewHistory.setBatchType("add");
  195. ptlTaxSourceNewHistory.setModifier(BaseController.getUser().getId());
  196. ptlTaxSourceNewHistory.setOperatorTime(LocalDateTime.now());
  197. ptlTaxSourceNewHistory.setPtlTaxSourceNewId(ptlTaxSourceNew.getId());
  198. //插入调度规则记录表
  199. ptlTaxSourceNewHistoryService.save(ptlTaxSourceNewHistory);
  200. //保存产品费用因子历史记录
  201. ptlAgreementDispatchRulesAttrLinkHistoryService.saveBatch(dispatchAttrLinkHistories);
  202. ptlAgreementDispatchRulesAttrLinkService.saveBatch(allAttrLink);
  203. }
  204. /**
  205. * @version
  206. * @author: hxl
  207. * @Date: 2024/5/29 10:37
  208. * @Description: 获取前台的值防止回显错误
  209. */
  210. private PtlAgreementDispatchRulesAttrLink getAttrLink(PtlAgreementDispatchRulesAttrLink x) {
  211. if ("1".equals(x.getOperator())) {
  212. //不处理
  213. //范围不处理
  214. } else if ("2".equals(x.getOperator())) {
  215. //将大于的值替换为null
  216. x.setMax(null);
  217. } else if ("3".equals(x.getOperator())) {
  218. //将大于的值替换为null
  219. x.setMax(null);
  220. } else if ("4".equals(x.getOperator())) {
  221. //将小于的值替换为null
  222. x.setMin(null);
  223. } else if ("5".equals(x.getOperator())) {
  224. //将小于的值替换为null
  225. x.setMin(null);
  226. }
  227. return x;
  228. }
  229. /**
  230. * @version
  231. * @author: hxl
  232. * @Date: 2024/5/29 10:37
  233. * @Description: 获取前台的值防止回显错误
  234. */
  235. private PtlAgreementDispatchRulesAttrLinkHistory getAttrLinkHistory(PtlAgreementDispatchRulesAttrLinkHistory x) {
  236. if ("1".equals(x.getOperator())) {
  237. //不处理
  238. //范围不处理
  239. } else if ("2".equals(x.getOperator())) {
  240. //将大于的值替换为null
  241. x.setMax(null);
  242. } else if ("3".equals(x.getOperator())) {
  243. //将大于的值替换为null
  244. x.setMax(null);
  245. } else if ("4".equals(x.getOperator())) {
  246. //将小于的值替换为null
  247. x.setMin(null);
  248. } else if ("5".equals(x.getOperator())) {
  249. //将小于的值替换为null
  250. x.setMin(null);
  251. }
  252. return x;
  253. }
  254. @Transactional
  255. @Override
  256. public void update(PtlTaxSourceNewAddVo ptlTaxSourceNewAddVo) {
  257. // int count= ptlTaxSourceNewMapper.findListByParams(ptlTaxSourceNewAddVo);
  258. // if(count>0){
  259. // throw new SystemException("该协议已经存在,不允许再次添加!!");
  260. // }
  261. //查询定义的规则表
  262. List<PtlAgreementDispatchRulesAttr> dispatchRulesAttrList = ptlAgreementDispatchRulesAttrService.getDispatchRulesAttrList();
  263. List<PtlAgreementDispatchRulesAttrLink> attrLinks = ptlTaxSourceNewAddVo.getAttrLinks();
  264. String content = RulesMergeStrUtils.getRulesMergeStr(attrLinks, dispatchRulesAttrList);
  265. if(content==null || "".equals(content)){
  266. throw new SystemException("规则列表未填写,请添加规则!!");
  267. }
  268. PtlTaxSourceNew ptlTaxSourceNewDefault= ptlTaxSourceNewMapper.findDefaultAttrLinkByInsCompanyId(ptlTaxSourceNewAddVo.getInsCompanyId());
  269. //修改
  270. PtlTaxSourceNew ptlTaxSourceNew = ptlTaxSourceNewMapper.selectById(ptlTaxSourceNewAddVo.getId());
  271. ptlTaxSourceNew =ptlTaxSourceNew.getNewEntity(ptlTaxSourceNewAddVo,ptlTaxSourceNew);
  272. if(ptlTaxSourceNewDefault!=null){
  273. //当前数据为默认的话,将之前的数据设置为非默认
  274. if("1".equals(ptlTaxSourceNew.getDefaultFlag()) ){
  275. //将旧数据设置数据为非默认
  276. ptlTaxSourceNewDefault.setDefaultFlag("0");
  277. ptlTaxSourceNewMapper.updateById(ptlTaxSourceNewDefault);
  278. }
  279. }
  280. ptlTaxSourceNew.setDispatchContent(content);
  281. ptlTaxSourceNew.setUpdateTime(new Date());
  282. ptlTaxSourceNew.setUpdateUser(BaseController.getUser().getId());
  283. ptlTaxSourceNewMapper.updateById(ptlTaxSourceNew);
  284. //先删除调度规则表信息
  285. ptlAgreementDispatchRulesAttrLinkService.remove(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttrLink>()
  286. .eq(PtlAgreementDispatchRulesAttrLink::getRulesId, ptlTaxSourceNew.getId()));
  287. //插入规则表
  288. List<PtlAgreementDispatchRulesAttrLink> allAttrLink = new ArrayList<>();
  289. List<PtlAgreementDispatchRulesAttrLinkHistory> dispatchAttrLinkHistories = new ArrayList<>();
  290. PtlTaxSourceNew finalPtlTaxSourceNew = ptlTaxSourceNew;
  291. //生成批次ID
  292. String uuid = IdGenerate.nextId();
  293. attrLinks.forEach(x -> {
  294. //转换数组
  295. if(x.getMinArray() != null && x.getMinArray().length > 0){
  296. x.setMin(String.join(",",x.getMinArray()));
  297. }
  298. //处理中文逗号
  299. if(x.getMin() != null && x.getMin().contains(",")) {
  300. x.setMin(x.getMin().replace(",",","));
  301. }
  302. //单独处理车牌号
  303. if ("LicenseNo".equals(x.getAttrCode()) && (x.getMin() != null && x.getMin() != "")) {
  304. x.setRulesId(finalPtlTaxSourceNew.getId()+"");
  305. x.setId("0");
  306. allAttrLink.add(x);
  307. //设置产品费用因子历史记录
  308. PtlAgreementDispatchRulesAttrLinkHistory dispatchAttrLinkHistory = new PtlAgreementDispatchRulesAttrLinkHistory();
  309. BeanUtils.copyProperties(x, dispatchAttrLinkHistory);
  310. dispatchAttrLinkHistory.setId(null);
  311. dispatchAttrLinkHistory.setBatch(uuid);
  312. dispatchAttrLinkHistory.setOperatorType("update");
  313. dispatchAttrLinkHistory.setModifier(BaseController.getUser().getId());
  314. dispatchAttrLinkHistory.setOperatorTime(LocalDateTime.now());
  315. dispatchAttrLinkHistories.add(dispatchAttrLinkHistory);
  316. } else {
  317. PtlAgreementDispatchRulesAttrLink finalX = x;
  318. PtlAgreementDispatchRulesAttr ptlAgreementDispatchRulesAttr = dispatchRulesAttrList.stream().filter(y -> y.getAttrCode().equals(finalX.getAttrCode())).findFirst().orElse(new PtlAgreementDispatchRulesAttr());
  319. //单独判断radio radio中存在0的属性值
  320. if ("radio".equals(ptlAgreementDispatchRulesAttr.getAttrType()) || "checkbox".equals(ptlAgreementDispatchRulesAttr.getAttrType())) {
  321. if (null != x.getMin() && !"".equals(x.getMin())) {
  322. x.setRulesId(finalPtlTaxSourceNew.getId()+"");
  323. x.setId("0");
  324. x=getAttrLink(x);
  325. allAttrLink.add(x);
  326. //设置产品费用因子历史记录
  327. PtlAgreementDispatchRulesAttrLinkHistory dispatchAttrLinkHistory = new PtlAgreementDispatchRulesAttrLinkHistory();
  328. BeanUtils.copyProperties(x, dispatchAttrLinkHistory);
  329. dispatchAttrLinkHistory.setId(null);
  330. dispatchAttrLinkHistory.setBatch(uuid);
  331. dispatchAttrLinkHistory.setOperatorType("update");
  332. dispatchAttrLinkHistory.setModifier(BaseController.getUser().getId());
  333. dispatchAttrLinkHistory.setOperatorTime(LocalDateTime.now());
  334. dispatchAttrLinkHistory=getAttrLinkHistory(dispatchAttrLinkHistory);
  335. dispatchAttrLinkHistories.add(dispatchAttrLinkHistory);
  336. }
  337. } else {
  338. if ( ( null != x.getMin() && !"0".equals(x.getMin()) && null != x.getOperator() && !"".equals(x.getOperator() )) || ( null != x.getMax() && !"0".equals(x.getMax()) && null != x.getOperator() && !"".equals(x.getOperator()) ) ) {
  339. x.setRulesId(finalPtlTaxSourceNew.getId()+"");
  340. x.setId("0");
  341. x=getAttrLink(x);
  342. allAttrLink.add(x);
  343. //设置产品费用因子历史记录
  344. PtlAgreementDispatchRulesAttrLinkHistory dispatchAttrLinkHistory = new PtlAgreementDispatchRulesAttrLinkHistory();
  345. BeanUtils.copyProperties(x, dispatchAttrLinkHistory);
  346. dispatchAttrLinkHistory.setId(null);
  347. dispatchAttrLinkHistory.setBatch(uuid);
  348. dispatchAttrLinkHistory.setOperatorType("update");
  349. dispatchAttrLinkHistory.setModifier(BaseController.getUser().getId());
  350. dispatchAttrLinkHistory.setOperatorTime(LocalDateTime.now());
  351. dispatchAttrLinkHistory=getAttrLinkHistory(dispatchAttrLinkHistory);
  352. dispatchAttrLinkHistories.add(dispatchAttrLinkHistory);
  353. }
  354. }
  355. }
  356. });
  357. //插入调度历史记录表
  358. //历史记录表
  359. PtlTaxSourceNewHistory ptlTaxSourceNewHistory=new PtlTaxSourceNewHistory();
  360. BeanUtils.copyProperties(ptlTaxSourceNew, ptlTaxSourceNewHistory);
  361. ptlTaxSourceNewHistory.setId(null);
  362. ptlTaxSourceNewHistory.setBatchId(uuid);
  363. ptlTaxSourceNewHistory.setBatchType("update");
  364. ptlTaxSourceNewHistory.setModifier(BaseController.getUser().getId());
  365. ptlTaxSourceNewHistory.setOperatorTime(LocalDateTime.now());
  366. ptlTaxSourceNewHistory.setPtlTaxSourceNewId(ptlTaxSourceNew.getId());
  367. //插入调度规则记录表
  368. ptlTaxSourceNewHistoryService.save(ptlTaxSourceNewHistory);
  369. //保存产品费用因子历史记录
  370. ptlAgreementDispatchRulesAttrLinkHistoryService.saveBatch(dispatchAttrLinkHistories);
  371. ptlAgreementDispatchRulesAttrLinkService.saveBatch(allAttrLink);
  372. }
  373. /**
  374. * @version
  375. * @author: hxl
  376. * @Date: 2024/5/22 15:44
  377. * @Description: 协议调度的删除
  378. */
  379. @Transactional
  380. @Override
  381. public void deleteByIds(List<Long> ids) {
  382. //通过ids查询到数据执行
  383. List<String> allLinkIds =new ArrayList<>();
  384. List<PtlAgreementDispatchRulesAttrLinkHistory> dispatchAttrLinkHistories =new ArrayList<>();
  385. List<PtlTaxSourceNewHistory> ptlTaxSourceNewHistorys =new ArrayList<>();
  386. if(ids!=null && ids.size()>0){
  387. //通过ids查询数据
  388. List<PtlTaxSourceNew> list= ptlTaxSourceNewMapper.findListByIds(ids);
  389. if(list!=null && list.size()>0){
  390. for(PtlTaxSourceNew ptlTaxSourceNew :list){
  391. String uuid = IdGenerate.nextId();
  392. List<PtlAgreementDispatchRulesAttrLink> linkList = ptlAgreementDispatchRulesAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttrLink>()
  393. .eq(PtlAgreementDispatchRulesAttrLink::getRulesId, ptlTaxSourceNew.getId()));
  394. if(linkList!=null && linkList.size()>0) {
  395. for (PtlAgreementDispatchRulesAttrLink ptlAgreementDispatchRulesAttrLink : linkList) {
  396. //放入删除的规则表ids
  397. allLinkIds.add(ptlAgreementDispatchRulesAttrLink.getId());
  398. //添加规则历史表
  399. PtlAgreementDispatchRulesAttrLinkHistory dispatchAttrLinkHistory = new PtlAgreementDispatchRulesAttrLinkHistory();
  400. BeanUtils.copyProperties(ptlAgreementDispatchRulesAttrLink, dispatchAttrLinkHistory);
  401. dispatchAttrLinkHistory.setId(null);
  402. dispatchAttrLinkHistory.setBatch(uuid);
  403. dispatchAttrLinkHistory.setOperatorType("delete");
  404. dispatchAttrLinkHistory.setModifier(BaseController.getUser().getId());
  405. dispatchAttrLinkHistory.setOperatorTime(LocalDateTime.now());
  406. dispatchAttrLinkHistories.add(dispatchAttrLinkHistory);
  407. }
  408. }
  409. //主表历史记录表
  410. PtlTaxSourceNewHistory ptlTaxSourceNewHistory=new PtlTaxSourceNewHistory();
  411. BeanUtils.copyProperties(ptlTaxSourceNew, ptlTaxSourceNewHistory);
  412. ptlTaxSourceNewHistory.setId(null);
  413. ptlTaxSourceNewHistory.setBatchId(uuid);
  414. ptlTaxSourceNewHistory.setBatchType("delete");
  415. ptlTaxSourceNewHistory.setModifier(BaseController.getUser().getId());
  416. ptlTaxSourceNewHistory.setOperatorTime(LocalDateTime.now());
  417. ptlTaxSourceNewHistory.setPtlTaxSourceNewId(ptlTaxSourceNew.getId());
  418. ptlTaxSourceNewHistorys.add(ptlTaxSourceNewHistory);
  419. }
  420. }
  421. }
  422. //插入历史记录表
  423. ptlTaxSourceNewHistoryService.saveBatch(ptlTaxSourceNewHistorys);
  424. ptlAgreementDispatchRulesAttrLinkHistoryService.saveBatch(dispatchAttrLinkHistories);
  425. //删除主表
  426. ptlTaxSourceNewMapper.deleteBatchIds(ids);
  427. //删除规则表
  428. ptlAgreementDispatchRulesAttrLinkService.removeByIds(allLinkIds);
  429. }
  430. /**
  431. * @version
  432. * @author: hxl
  433. * @Date: 2024/5/22 15:37
  434. * @Description: 保存排除部门信息
  435. */
  436. @Override
  437. @Transactional
  438. public void saveDeptIds(PtlTaxSourceNewAddDeptIdsVo taxSourceVo) {
  439. //删除排除的信息
  440. taxSourceExcludeService.remove(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getInsCompanyId, taxSourceVo.getInsCompanyId()));
  441. List<TaxSourceExcludeDto> excludeDtos = new ArrayList<>();
  442. //组装排除的部门信息
  443. if(taxSourceVo.getAgreementTaxExcludeDeptList()!=null && taxSourceVo.getAgreementTaxExcludeDeptList().size()>0){
  444. for (String agreementTaxExclude : taxSourceVo.getAgreementTaxExcludeDeptList()) {
  445. TaxSourceExcludeDto dto = new TaxSourceExcludeDto();
  446. dto.setType(Integer.parseInt(TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
  447. dto.setInsCompanyId(taxSourceVo.getInsCompanyId());
  448. dto.setExcludeInfo(agreementTaxExclude);
  449. excludeDtos.add(dto);
  450. }
  451. taxSourceExcludeService.saveBatch(excludeDtos);
  452. }
  453. }
  454. /**
  455. * @version
  456. * @author: hxl
  457. * @Date: 2024/5/22 15:57
  458. * @Description: 通过保险公司id查询绑定的排除部门id
  459. */
  460. @Override
  461. public List<String> getDeptIdsByCompanyId(String companyId) {
  462. //排除的部门信息
  463. List<TaxSourceExcludeDto> taxSourceExcludeDepts =
  464. taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getInsCompanyId, companyId).eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
  465. //部门信息转换
  466. List<String> agreementTaxExcludeDepts = new ArrayList<>();
  467. taxSourceExcludeDepts.forEach(item -> {
  468. agreementTaxExcludeDepts.add(item.getExcludeInfo());
  469. });
  470. PtlTaxSourceNewAddDeptIdsVo vo=new PtlTaxSourceNewAddDeptIdsVo();
  471. vo.setAgreementTaxExcludeDeptList(agreementTaxExcludeDepts);
  472. return agreementTaxExcludeDepts;
  473. }
  474. /**
  475. * 根据税源获取协议id
  476. * @param deptId
  477. * @param userId
  478. * @param companyId
  479. * @param quoteInfo 报价信息
  480. * @return
  481. */
  482. @Override
  483. public String getAgreementId(String deptId, String userId, String companyId, BaseQuoteInfoVo quoteInfo, String riskCode,String orderno) {
  484. //通过订单号获取报价信息 防止从redis中获取的数据不对
  485. InsOrders insOrders = insOrdersService.getById(orderno);
  486. quoteInfo = new BaseQuoteInfoVo(insOrders);
  487. List<PtlAgreementDispatchRulesAttr> dispatchRulesAttrList = ptlAgreementDispatchRulesAttrService.getDispatchRulesAttrList();
  488. String resultId = "";
  489. //查找配置的默认项,匹配不到赋值默认的协议Id
  490. List<PtlTaxSourceNew> taxSourceDtoList = baseMapper.selectList(new LambdaQueryWrapper<PtlTaxSourceNew>()
  491. .eq(PtlTaxSourceNew::getInsCompanyId,companyId)
  492. .eq(PtlTaxSourceNew::getDefaultFlag,"1"));
  493. if(taxSourceDtoList.isEmpty()){
  494. throw new SystemException("没有匹配到默认协议,请添加!");
  495. }
  496. //默认协议
  497. String agreeId = taxSourceDtoList.get(0).getAgreementId();
  498. logger.info("======================默认协议为:"+agreeId+"==================================");
  499. //通过公司id按优先级排序获取协议规则
  500. List<PtlTaxSourceNew> prioritySortList = baseMapper.selectList(new LambdaQueryWrapper<PtlTaxSourceNew>()
  501. .eq(PtlTaxSourceNew::getInsCompanyId,companyId)
  502. .orderByAsc(PtlTaxSourceNew::getPriority));
  503. boolean isExclude = true;
  504. //排除的部门信息
  505. //List<TaxSourceExcludeDto> excludeDepts =
  506. // taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getExcludeInfo, deptId).eq(TaxSourceExcludeDto::getInsCompanyId, companyId).eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
  507. //部门排除
  508. // if (excludeDepts.stream().anyMatch(taxSourceDto -> taxSourceDto.getExcludeInfo().equals(deptId))) {
  509. // isExclude = false;
  510. // }
  511. if(prioritySortList!=null && !prioritySortList.isEmpty()){
  512. int size = prioritySortList.size();
  513. for (int i = 0; i < size; i++) {
  514. //判断是否为空,如果不为空直接跳出
  515. String checkAgreementId = getAgreementId(prioritySortList.get(i), quoteInfo, dispatchRulesAttrList, isExclude,orderno,userId);
  516. if(!"".equals(checkAgreementId)){
  517. resultId=checkAgreementId;
  518. logger.info("匹配的协议为:"+resultId);
  519. break;
  520. }
  521. }
  522. }
  523. //如果没有匹配上协议,直接赋值默认协议
  524. if("".equals(resultId)){
  525. resultId= agreeId;
  526. }
  527. return resultId;
  528. }
  529. /**
  530. * @version
  531. * @author: hxl
  532. * @Date: 2024/5/28 14:27
  533. * @Description: 通过规则判断是否匹配
  534. */
  535. public String getAgreementId(PtlTaxSourceNew ptlTaxSourceNew,BaseQuoteInfoVo quoteInfo, List<PtlAgreementDispatchRulesAttr> dispatchRulesAttrList,boolean isExclude,String orderno,String userId){
  536. String quoteInfoErorMsg="";
  537. String msg="";
  538. String agreementId="";
  539. //1.车牌号
  540. String licenseNo = quoteInfo.getCarInfo().getLicenseNo();
  541. //2 座位数
  542. String seats = quoteInfo.getCarInfo().getSeatCount();
  543. // 3.排量
  544. String exhaustScale = quoteInfo.getCarInfo().getEnginedesc();
  545. // 4.车辆大类
  546. String cimodelclass = quoteInfo.getCarInfo().getCimodelclass();
  547. //5.使用性质
  548. String vehicleUse = quoteInfo.getCarInfo().getVehicleUse();
  549. //code变为name
  550. String cimodelclassVal = getPtlAgreementDispatchRulesAttr(dispatchRulesAttrList, DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_4.getCode(),cimodelclass);
  551. String vehicleUseVal = getPtlAgreementDispatchRulesAttr(dispatchRulesAttrList, DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_5.getCode(),vehicleUse);
  552. List<KindInfoVo> kinds = quoteInfo.getKindList();
  553. List<RiskInfoVo> risks = quoteInfo.getRiskList();
  554. //6.交强投保
  555. String yqInsureFlag = !InsuranceRisk.getFlagByTRAFFIC(risks) ?"0":"1";
  556. //7.车损投保
  557. String cxInsureFlag = !InsuranceRisk.getFlagByA(kinds) ?"0":"1";
  558. //8.第三者责任险
  559. String thirdPartyLiabilityInsurance =InsuranceRisk.getStringByB(kinds);
  560. //报价信息
  561. msg = getString(msg, licenseNo,seats,exhaustScale,cimodelclassVal,vehicleUseVal,yqInsureFlag,cxInsureFlag,thirdPartyLiabilityInsurance);
  562. //通过调度id查询调度规则是否包含车牌、排量
  563. boolean isExcludeLicense = false;
  564. boolean isExcludeSeats = false;
  565. boolean isExcludeVolume= false;
  566. boolean isExcludeCimodelclass= false;
  567. boolean isExcludeVehicleUse= false;
  568. boolean isExcludeYqInsureFlag= false;
  569. boolean isExcludeCxInsureFlag= false;
  570. boolean isExcludeThirdPartyLiabilityInsurance= false;
  571. //通过默认公司id查询所有的协议按优先级排序
  572. Long ptlTaxSourceNewId = ptlTaxSourceNew.getId();
  573. List<PtlAgreementDispatchRulesAttrLink> list = ptlAgreementDispatchRulesAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttrLink>()
  574. .eq(PtlAgreementDispatchRulesAttrLink::getRulesId, ptlTaxSourceNewId));
  575. //为匹配信息拼接
  576. if(list!=null && list.size()>0 ){
  577. isExcludeLicense = judgeIsExcludeFlag(licenseNo, list, dispatchRulesAttrList,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_1.getCode());
  578. if(!isExcludeLicense){
  579. quoteInfoErorMsg+=DispatchTypeConstants.matchKey(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_1.getCode())+"的值为"+licenseNo+"未匹配"+"\n";
  580. }
  581. isExcludeSeats = judgeIsExcludeFlag(seats, list, dispatchRulesAttrList,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_2.getCode());
  582. if(!isExcludeSeats){
  583. quoteInfoErorMsg+=DispatchTypeConstants.matchKey(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_2.getCode())+"的值为"+seats+"未匹配"+"\n";
  584. }
  585. isExcludeVolume =judgeIsExcludeFlag(exhaustScale, list, dispatchRulesAttrList,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_3.getCode());
  586. if(!isExcludeVolume){
  587. quoteInfoErorMsg+=DispatchTypeConstants.matchKey(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_3.getCode())+"的值为"+exhaustScale+"未匹配"+"\n";
  588. }
  589. isExcludeCimodelclass = judgeIsExcludeFlag(cimodelclassVal, list, dispatchRulesAttrList,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_4.getCode());
  590. if(!isExcludeCimodelclass){
  591. quoteInfoErorMsg+=DispatchTypeConstants.matchKey(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_4.getCode())+"的值为"+cimodelclassVal+"未匹配"+"\n";
  592. }
  593. isExcludeVehicleUse = judgeIsExcludeFlag(vehicleUseVal, list, dispatchRulesAttrList,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_5.getCode());
  594. if(!isExcludeVehicleUse){
  595. quoteInfoErorMsg+=DispatchTypeConstants.matchKey(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_5.getCode())+"的值为"+vehicleUseVal+"未匹配"+"\n";
  596. }
  597. isExcludeYqInsureFlag = judgeIsExcludeFlag(yqInsureFlag, list, dispatchRulesAttrList,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_6.getCode());
  598. if(!isExcludeYqInsureFlag){
  599. quoteInfoErorMsg+=DispatchTypeConstants.matchKey(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_6.getCode())+"的值为"+("1".equals(yqInsureFlag)?"是":"否")+"未匹配"+"\n";
  600. }
  601. isExcludeCxInsureFlag = judgeIsExcludeFlag(cxInsureFlag, list, dispatchRulesAttrList,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_7.getCode());
  602. if(!isExcludeCxInsureFlag){
  603. quoteInfoErorMsg+=DispatchTypeConstants.matchKey(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_7.getCode())+"的值为"+("1".equals(cxInsureFlag)?"是":"否")+"未匹配"+"\n";
  604. }
  605. isExcludeThirdPartyLiabilityInsurance = judgeIsExcludeFlag(thirdPartyLiabilityInsurance, list, dispatchRulesAttrList,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_8.getCode());
  606. if(!isExcludeThirdPartyLiabilityInsurance){
  607. quoteInfoErorMsg+= DispatchTypeConstants.matchKey(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_8.getCode())+"的值为"+(thirdPartyLiabilityInsurance==null?"不投保":thirdPartyLiabilityInsurance)+"未匹配"+"\n";
  608. }
  609. }
  610. logger.info("==============================="+ptlTaxSourceNew.getAgreementId()+"协议调度规则对象为:"+ptlTaxSourceNew.toString()+"=====================================");
  611. logger.info("==============================="+ptlTaxSourceNew.getAgreementId()+"协议调度规则内容为:"+ptlTaxSourceNew.getDispatchContent()+"===============================");
  612. logger.info("==============================="+ptlTaxSourceNew.getAgreementId()+"报价参数信息为:"+msg+"===============================");
  613. logger.info("==============================="+ptlTaxSourceNew.getAgreementId()+"未匹配信息为:"+quoteInfoErorMsg+"===============================");
  614. //if (isExclude && isExcludeLicense && isExcludeSeats && isExcludeVolume && isExcludeCimodelclass && isExcludeVehicleUse && isExcludeYqInsureFlag && isExcludeCxInsureFlag && isExcludeThirdPartyLiabilityInsurance ) {
  615. if (isExcludeLicense && isExcludeSeats && isExcludeVolume && isExcludeCimodelclass && isExcludeVehicleUse && isExcludeYqInsureFlag && isExcludeCxInsureFlag && isExcludeThirdPartyLiabilityInsurance ) {
  616. agreementId = ptlTaxSourceNew.getAgreementId();
  617. }
  618. PtlTaxSourceNewRecord ptlTaxSourceNewRecord=new PtlTaxSourceNewRecord(orderno, ptlTaxSourceNew.toString(), ptlTaxSourceNew.getDispatchContent(), msg, quoteInfoErorMsg,new Date(), userId);
  619. ptlTaxSourceNewRecordService.save(ptlTaxSourceNewRecord);
  620. return agreementId;
  621. }
  622. /**
  623. * @version
  624. * @author: hxl
  625. * @Date: 2024/5/28 11:51
  626. * @Description: 根据code获取名称值
  627. */
  628. private static String getPtlAgreementDispatchRulesAttr(List<PtlAgreementDispatchRulesAttr> dispatchRulesAttrList, String code,String
  629. val) {
  630. String val_new="";
  631. PtlAgreementDispatchRulesAttr ptlAgreementDispatchRulesAttr = dispatchRulesAttrList.stream().filter(y -> y.getAttrCode().equals(code)).findFirst().orElse(new PtlAgreementDispatchRulesAttr());
  632. List<PtlAgreementDispatchRulesDictLabal> dictLabal = ptlAgreementDispatchRulesAttr.getDictLabal();
  633. if(dictLabal!=null && dictLabal.size()>0){
  634. for(PtlAgreementDispatchRulesDictLabal ptlAgreementDispatchRulesDictLabal: dictLabal){
  635. if(val.equals(ptlAgreementDispatchRulesDictLabal.getCode())){
  636. val_new=ptlAgreementDispatchRulesDictLabal.getName();
  637. }
  638. }
  639. }
  640. return ptlAgreementDispatchRulesAttr.getDictLabal()==null?"":val_new;
  641. }
  642. /**
  643. * @version
  644. * @author: hxl
  645. * @Date: 2024/5/28 9:12
  646. * @Description: 前台信息拼接
  647. */
  648. private static String getString(String allMag, String val1,String val2,String val3,String val4,String val5,String val6,String val7,String val8) {
  649. String msg="";
  650. allMag += getAllString(msg, val1,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_1.getCode());
  651. allMag +=getAllString(msg, val2,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_2.getCode());
  652. allMag +=getAllString(msg, val3,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_3.getCode());
  653. allMag +=getAllString(msg, val4,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_4.getCode());
  654. allMag +=getAllString(msg, val5,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_5.getCode());
  655. allMag +=getAllString(msg, "1".equals(val6)?"是":"否",DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_6.getCode());
  656. allMag +=getAllString(msg, "1".equals(val7)?"是":"否",DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_7.getCode());
  657. allMag +=getAllString(msg, val8,DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_8.getCode());
  658. return allMag;
  659. }
  660. /**
  661. * @version
  662. * @author: hxl
  663. * @Date: 2024/5/28 9:08
  664. * @Description: 信息拼接
  665. */
  666. private static String getAllString(String msg, String val,String code) {
  667. if(DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_8.getCode().equals(code)){
  668. val= val==null?"不投保":val;
  669. }else{
  670. val= val==null?"空":val;
  671. }
  672. msg +=DispatchTypeConstants.matchKey(code)+"的值为" +val+"\n";
  673. return msg;
  674. }
  675. /**
  676. * @version
  677. * @author: hxl
  678. * @Date: 2024/5/28 8:43
  679. * @Description: 判断值是否和规则匹配
  680. */
  681. private static boolean judgeIsExcludeFlag(String val, List<PtlAgreementDispatchRulesAttrLink> list, List<PtlAgreementDispatchRulesAttr> dispatchRulesAttrList,String code) {
  682. boolean isExcludeFlag;
  683. if(StringUtils.isBlank(val)){
  684. if(!DispatchTypeConstants.removalOfCode().contains(code)){
  685. throw new SystemException(DispatchTypeConstants.matchKey(code)+"不能为空");
  686. }
  687. }
  688. isExcludeFlag = RulesMergeStrUtils.judgeVal(list, (DispatchTypeConstants.DISPATCH_TYPE_CONSTANTS_1.getCode().equals(code))?val.substring(0, 2):val, code, dispatchRulesAttrList);
  689. return isExcludeFlag;
  690. }
  691. /**
  692. * @version
  693. * @author: hxl
  694. * @Date: 2024/5/24 18:06
  695. * @Description: 通过id查询对象
  696. */
  697. @Override
  698. public PtlTaxSourceNewSaveVo rulesGet(Long id, List<PtlAgreementDispatchRulesAttr> dispatchRulesAttrList) {
  699. //设置费用因子属性
  700. List<PtlAgreementDispatchRulesAttr> ptlAgreementDispatchRulesAttrs = new ArrayList<>();
  701. List<PtlAgreementDispatchRulesAttrLink> list = ptlAgreementDispatchRulesAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttrLink>()
  702. .eq(PtlAgreementDispatchRulesAttrLink::getRulesId, id));
  703. dispatchRulesAttrList.stream().forEach(x -> {
  704. //处理多选和下拉
  705. if ("checkbox".equals(x.getAttrType()) || "select".equals(x.getAttrType())) {
  706. //处理车牌
  707. if ("select".equals(x.getAttrType()) && "LicenseNo".equals(x.getAttrCode())) {
  708. PtlAgreementDispatchRulesAttrLink licenseNo = list.stream().filter(l -> l.getAttrCode().equals("LicenseNo")).findFirst().orElse(new PtlAgreementDispatchRulesAttrLink());
  709. if (licenseNo != null) {
  710. //根据operator 获取车牌的地区id
  711. List<PtlAreaLicense> byParentNumber = ptlAreaLicenseService.getByParentNumber("14");
  712. //ptlAreaLicenseService.getByParentNumber()
  713. List<PtlAgreementDispatchRulesDictLabal> dictLabal = byParentNumber.stream().map(y -> {
  714. PtlAgreementDispatchRulesDictLabal ptlAgreementDispatchRulesDictLabal = new PtlAgreementDispatchRulesDictLabal();
  715. ptlAgreementDispatchRulesDictLabal.setDictId(y.getId());
  716. ptlAgreementDispatchRulesDictLabal.setCode(y.getAreaNumber());
  717. ptlAgreementDispatchRulesDictLabal.setName(y.getLicense());
  718. return ptlAgreementDispatchRulesDictLabal;
  719. }).collect(Collectors.toList());
  720. x.setDictLabal(dictLabal);
  721. }
  722. }
  723. x.setMinArray(new String[]{});
  724. list.stream().filter(y -> y.getAttrCode().equals(x.getAttrCode())).findFirst().ifPresent(z -> {
  725. if (null != z.getMin()) {
  726. x.setId(z.getId());
  727. x.setMinArray(z.getMin().split(","));
  728. x.setMax(z.getMax());
  729. x.setOperator(z.getOperator());
  730. }
  731. });
  732. } else {
  733. list.stream().filter(y -> y.getAttrCode().equals(x.getAttrCode())).findFirst().ifPresent(z -> {
  734. x.setId(z.getId());
  735. x.setMin(z.getMin());
  736. x.setMax(z.getMax());
  737. x.setOperator(z.getOperator());
  738. });
  739. }
  740. ptlAgreementDispatchRulesAttrs.add(x);
  741. });
  742. PtlTaxSourceNew ptlTaxSourceNew = this.getById(id);
  743. PtlTaxSourceNewSaveVo ptlTaxSourceNewSaveVo =new PtlTaxSourceNewSaveVo(ptlTaxSourceNew);
  744. ptlTaxSourceNewSaveVo.setAttrLinks(ptlAgreementDispatchRulesAttrs);
  745. return ptlTaxSourceNewSaveVo;
  746. }
  747. }