DyoaHistoryServiceImpl.java 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562
  1. package com.dayou.dyoa;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import cn.hutool.core.collection.CollectionUtil;
  4. import cn.hutool.core.util.StrUtil;
  5. import com.alibaba.fastjson.JSON;
  6. import com.alibaba.fastjson.JSONArray;
  7. import com.alibaba.fastjson.JSONException;
  8. import com.alibaba.fastjson.JSONObject;
  9. import com.baomidou.dynamic.datasource.annotation.DS;
  10. import com.baomidou.dynamic.datasource.annotation.DSTransactional;
  11. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  12. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  13. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  14. import com.dayou.common.BaseEntity;
  15. import com.dayou.dto.history.*;
  16. import com.dayou.entity.*;
  17. import com.dayou.enums.MainBusinessEnum;
  18. import com.dayou.enums.ProductionEnum;
  19. import com.dayou.exception.ErrorCode;
  20. import com.dayou.mapper.*;
  21. import com.dayou.service.*;
  22. import com.dayou.service.impl.AssetsServiceImpl;
  23. import com.dayou.utils.DateUtils;
  24. import com.dayou.utils.HttpKit;
  25. import lombok.extern.slf4j.Slf4j;
  26. import org.apache.http.HttpResponse;
  27. import org.apache.http.client.HttpClient;
  28. import org.apache.http.client.methods.HttpPost;
  29. import org.apache.http.impl.client.DefaultHttpClient;
  30. import org.springframework.beans.factory.annotation.Autowired;
  31. import org.springframework.stereotype.Service;
  32. import java.io.UnsupportedEncodingException;
  33. import java.lang.reflect.Field;
  34. import java.math.BigDecimal;
  35. import java.sql.Timestamp;
  36. import java.time.LocalDate;
  37. import java.time.LocalDateTime;
  38. import java.util.*;
  39. import java.util.regex.Matcher;
  40. import java.util.regex.Pattern;
  41. import java.util.stream.Collectors;
  42. import static com.dayou.common.Constants.*;
  43. import static com.dayou.enums.MainBusinessEnum.*;
  44. @DS("dyoa")
  45. @Service
  46. @Slf4j
  47. public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
  48. private static String COOKIE ;
  49. private static final String HISTORY_LOGIN_URL = "http://noa.scdayou.com/login?loginName=admin&password=root1234";
  50. private static final String HISTORY_MAJOR_ORDER_URL = "http://noa.scdayou.com/dyoa/order/pageQuery";
  51. private static final String HISTORY_ASSETS_ORDER_URL = "http://noa.scdayou.com/dyoa/assets/assets/pageQuery";
  52. private Map<String,Long> users = new HashMap<>();
  53. private Map<String,Long> departments = new HashMap<>();
  54. // private Map<String,Long> realAmounts = new HashMap<>();
  55. // private Map<String,Long> orderFundIds = new HashMap<>();
  56. // private Map<String,Long> productionFundIds = new HashMap<>();
  57. //
  58. // private Map<Long,Long> orderFundIdProdFundIds = new HashMap<>();
  59. private static final Map<String,String> MAJOR_ORDER_COLUM = new HashMap<>();
  60. private static final Map<String,String> MAJOR_PRODUCTION_COLUM = new HashMap<>();
  61. private static final Map<String,String> PERSONAL_ORDER_COLUM = new HashMap<>();
  62. private static final Map<String,String> REAL_AMOUNT_COLUM = new HashMap<>();
  63. private static final Map<String,String> REAL_AMOUNT_CLAIM_COLUM = new HashMap<>();
  64. private static final Map<String,String> ASSETS_ORDER_COLUM = new HashMap<>();
  65. private static final Map<String,String> ASSETS_PRODUCTION_COLUM = new HashMap<>();
  66. private static final Map<String,String> FINANCE_INVOICE_COLUM = new HashMap<>();
  67. @Autowired
  68. private IUserService userService;
  69. @Autowired
  70. private IDepartmentService departmentService;
  71. @Autowired
  72. private DyoaHistoryMapper dyoaHistoryMapper;
  73. @Autowired
  74. private IDyoaRecordService dyoaRecordService;
  75. @Autowired
  76. private IFinanceRealFundService financeRealFundService;
  77. @Autowired
  78. private IOrderFundService orderFundService;
  79. @Autowired
  80. private IProductionFundService productionFundService;
  81. @Autowired
  82. private IMajorService majorServiceImpl;
  83. @Autowired
  84. private IMajorProductionService majorProductionService;
  85. @Autowired
  86. private IPersonalService personalService;
  87. @Autowired
  88. private ICustomerCompanyService customerCompanyService;
  89. @Autowired
  90. private ICustomerLinkmanService customerLinkmanService;
  91. @Autowired
  92. private IAssetsService assetsService;
  93. @Autowired
  94. private IFinanceClaimService financeClaimService;
  95. @Autowired
  96. private IAssetsService assetsServiceImpl;
  97. @Autowired
  98. private IAssetsProductionService assetsProductionService;
  99. @Autowired
  100. private IFinanceInvoiceService financeInvoiceService;
  101. @Autowired
  102. private IPersonalTargetService personalTargetService;
  103. static {
  104. // MAJOR_ORDER_COLUM.put("id","id");
  105. MAJOR_ORDER_COLUM.put("name","name");
  106. MAJOR_ORDER_COLUM.put("code","orderId");
  107. MAJOR_ORDER_COLUM.put("sourceType","financial");
  108. MAJOR_ORDER_COLUM.put("assign","allotType");
  109. MAJOR_ORDER_COLUM.put("masterName","clientManagerId");
  110. MAJOR_ORDER_COLUM.put("managerName","principalId");
  111. MAJOR_ORDER_COLUM.put("masterOrgName","departmentId");
  112. MAJOR_ORDER_COLUM.put("businessType","businessObjectType");
  113. MAJOR_ORDER_COLUM.put("businessType2","businessGener");
  114. MAJOR_ORDER_COLUM.put("spec","specialType");
  115. MAJOR_ORDER_COLUM.put("evaluateTarget","evaluateAim");
  116. MAJOR_ORDER_COLUM.put("repeatOrder","entrustAgain");
  117. MAJOR_ORDER_COLUM.put("fhbq","multipleRemoval");
  118. MAJOR_ORDER_COLUM.put("oral","informalEvaluate");
  119. MAJOR_ORDER_COLUM.put("customerType","clienteleType");
  120. MAJOR_ORDER_COLUM.put("cz","dispenseBenefit");
  121. MAJOR_ORDER_COLUM.put("locations","nonnative");
  122. MAJOR_ORDER_COLUM.put("refinance","refinance");
  123. MAJOR_ORDER_COLUM.put("loanMoney","loanLimit");
  124. MAJOR_ORDER_COLUM.put("loanLimit","loanPeriod");
  125. MAJOR_ORDER_COLUM.put("loanProperty","loanNature");
  126. MAJOR_ORDER_COLUM.put("loanUsage","loanAim");
  127. MAJOR_ORDER_COLUM.put("loanExpired","loanExpire");
  128. MAJOR_ORDER_COLUM.put("principal","bailor");
  129. MAJOR_ORDER_COLUM.put("principalAddress","bailorAddress");
  130. MAJOR_ORDER_COLUM.put("principalName","bailorContactName");
  131. MAJOR_ORDER_COLUM.put("principalMobile","bailorContactTel");
  132. MAJOR_ORDER_COLUM.put("propertyName","owner");
  133. MAJOR_ORDER_COLUM.put("propertyMobile","ownerTel");
  134. MAJOR_ORDER_COLUM.put("urgent","urgent");
  135. MAJOR_ORDER_COLUM.put("terminalType","terminalClienteleType");
  136. MAJOR_ORDER_COLUM.put("members","members");
  137. MAJOR_ORDER_COLUM.put("description","remark");
  138. MAJOR_ORDER_COLUM.put("customerName","clienteleId");
  139. MAJOR_ORDER_COLUM.put("customerName2","clienteleSubId");
  140. MAJOR_ORDER_COLUM.put("bankContactName","clienteleContactId");
  141. MAJOR_ORDER_COLUM.put("terminalName","terminalClienteleId");
  142. MAJOR_ORDER_COLUM.put("terminalContactName","terminalClienteleContactId");
  143. //大中型产品字段
  144. MAJOR_PRODUCTION_COLUM.put("pType","production");
  145. MAJOR_PRODUCTION_COLUM.put("reportNo","reportNo");
  146. MAJOR_PRODUCTION_COLUM.put("signEmpNames","signatory");
  147. MAJOR_PRODUCTION_COLUM.put("name","name");
  148. MAJOR_PRODUCTION_COLUM.put("principal","clientName");
  149. MAJOR_PRODUCTION_COLUM.put("principalAddress","clientAddress");
  150. MAJOR_PRODUCTION_COLUM.put("principalMobile","clientTel");
  151. MAJOR_PRODUCTION_COLUM.put("propertyName","owner");
  152. MAJOR_PRODUCTION_COLUM.put("priceDate","valueTiming");
  153. MAJOR_PRODUCTION_COLUM.put("area","evaluateAcreage");
  154. MAJOR_PRODUCTION_COLUM.put("money","evaluateAmount");
  155. MAJOR_PRODUCTION_COLUM.put("xPrice","evaluatePrice");
  156. MAJOR_PRODUCTION_COLUM.put("specDesc","comment");
  157. MAJOR_PRODUCTION_COLUM.put("repo","repertoryState");
  158. MAJOR_PRODUCTION_COLUM.put("yjsInTime","repertoryInTime");
  159. MAJOR_PRODUCTION_COLUM.put("yjsOutTime","repertoryOutTime");
  160. MAJOR_PRODUCTION_COLUM.put("bgInTime","repertoryInTime");
  161. MAJOR_PRODUCTION_COLUM.put("bgOutTime","repertoryOutTime");
  162. MAJOR_PRODUCTION_COLUM.put("archiveTime","saveFileDate");
  163. MAJOR_PRODUCTION_COLUM.put("standardPrice","standardAmount");
  164. MAJOR_PRODUCTION_COLUM.put("confirmTime","deliveryDate");
  165. MAJOR_PRODUCTION_COLUM.put("deliveryState","delivery");
  166. MAJOR_PRODUCTION_COLUM.put("printQuantity","printTimes");
  167. //个贷订单字段
  168. PERSONAL_ORDER_COLUM.put("orderNo","orderId");
  169. PERSONAL_ORDER_COLUM.put("locations","location");
  170. PERSONAL_ORDER_COLUM.put("target","evaluateAim");
  171. PERSONAL_ORDER_COLUM.put("purpose","purpose");
  172. PERSONAL_ORDER_COLUM.put("loanMaxMoney","loanLimit");
  173. PERSONAL_ORDER_COLUM.put("loanMaxYear","loanPeriod");
  174. PERSONAL_ORDER_COLUM.put("masterName","clientManagerId");
  175. PERSONAL_ORDER_COLUM.put("principal1","bailorA");
  176. PERSONAL_ORDER_COLUM.put("principal1Mobile","bailoraTel");
  177. PERSONAL_ORDER_COLUM.put("principal2","bailorB");
  178. PERSONAL_ORDER_COLUM.put("principal2Mobile","bailorbTel");
  179. PERSONAL_ORDER_COLUM.put("description","remark");
  180. PERSONAL_ORDER_COLUM.put("outerEmpName","outwardStaff");
  181. PERSONAL_ORDER_COLUM.put("productEmpName","inwardStaff");
  182. PERSONAL_ORDER_COLUM.put("priceEmpName","pricingStaff");
  183. PERSONAL_ORDER_COLUM.put("agent","agent");
  184. PERSONAL_ORDER_COLUM.put("loanProperty","loanNature");
  185. PERSONAL_ORDER_COLUM.put("loanUsage","loanAim");
  186. PERSONAL_ORDER_COLUM.put("loanExpired","loanExpire");
  187. PERSONAL_ORDER_COLUM.put("customerType","clienteleType");
  188. PERSONAL_ORDER_COLUM.put("customerName","clienteleId");
  189. PERSONAL_ORDER_COLUM.put("customerName2","clienteleSubId");
  190. PERSONAL_ORDER_COLUM.put("bankContactName","clienteleContactId");
  191. PERSONAL_ORDER_COLUM.put("terminalType","terminalClienteleType");
  192. PERSONAL_ORDER_COLUM.put("terminalName","terminalClienteleId");
  193. PERSONAL_ORDER_COLUM.put("terminalContactName","terminalClienteleContactId");
  194. PERSONAL_ORDER_COLUM.put("finished","ifSaveFile");
  195. PERSONAL_ORDER_COLUM.put("finishTime","saveFileDate");
  196. PERSONAL_ORDER_COLUM.put("files","credentials");
  197. //实收款字段
  198. REAL_AMOUNT_COLUM.put("incomeTime","payDatetime");
  199. REAL_AMOUNT_COLUM.put("companyName","payer");
  200. REAL_AMOUNT_COLUM.put("bankName","payerBank");
  201. REAL_AMOUNT_COLUM.put("bankNo","payerAccount");
  202. REAL_AMOUNT_COLUM.put("money","amount");
  203. REAL_AMOUNT_COLUM.put("description","remark");
  204. REAL_AMOUNT_COLUM.put("creatorName","creatorId");
  205. //实收款认领记录
  206. REAL_AMOUNT_CLAIM_COLUM.put("orderId","orderFundId");
  207. REAL_AMOUNT_CLAIM_COLUM.put("incomeId","realFundId");
  208. REAL_AMOUNT_CLAIM_COLUM.put("money","claimAmount");
  209. REAL_AMOUNT_CLAIM_COLUM.put("takeEmpName","claimUserId");
  210. REAL_AMOUNT_CLAIM_COLUM.put("createdDatetime","claimDatetime");
  211. //资产订单字段
  212. ASSETS_ORDER_COLUM.put("masterName","clientManagerId");
  213. ASSETS_ORDER_COLUM.put("assign","allotType");
  214. ASSETS_ORDER_COLUM.put("masterOrgName","departmentId");
  215. ASSETS_ORDER_COLUM.put("code","orderId");
  216. ASSETS_ORDER_COLUM.put("name","name");
  217. ASSETS_ORDER_COLUM.put("businessType","assetsBusinessGener");
  218. ASSETS_ORDER_COLUM.put("managerName","principalId");
  219. ASSETS_ORDER_COLUM.put("companyName","clienteleSubId");
  220. ASSETS_ORDER_COLUM.put("principal","bailor");
  221. ASSETS_ORDER_COLUM.put("principalName","bailorContactName");
  222. ASSETS_ORDER_COLUM.put("principalMobile","bailorContactTel");
  223. ASSETS_ORDER_COLUM.put("description","remark");
  224. ASSETS_ORDER_COLUM.put("customerType","clienteleType");
  225. ASSETS_ORDER_COLUM.put("customerName","clienteleId");
  226. ASSETS_ORDER_COLUM.put("bankContactName","clienteleContactId");
  227. ASSETS_ORDER_COLUM.put("terminalType","terminalClienteleType");
  228. ASSETS_ORDER_COLUM.put("terminalName","terminalClienteleId");
  229. ASSETS_ORDER_COLUM.put("terminalContactName","terminalClienteleContactId");
  230. ASSETS_ORDER_COLUM.put("importantAsset","significantAssetsReorganization");
  231. ASSETS_ORDER_COLUM.put("stateOwned","stateAssets");
  232. ASSETS_ORDER_COLUM.put("abroadAsset","foreignAssetsInvolved");
  233. ASSETS_ORDER_COLUM.put("cz","dispenseBenefit");
  234. ASSETS_ORDER_COLUM.put("stock","security");
  235. ASSETS_ORDER_COLUM.put("repeatOrder","entrustAgain");
  236. //资产产品字段
  237. ASSETS_PRODUCTION_COLUM.put("principal","clientName");
  238. ASSETS_PRODUCTION_COLUM.put("principalMobile","clientTel");
  239. ASSETS_PRODUCTION_COLUM.put("money","evaluateAmount");
  240. ASSETS_PRODUCTION_COLUM.put("area","evaluateAcreage");
  241. ASSETS_PRODUCTION_COLUM.put("price","evaluatePrice");
  242. ASSETS_PRODUCTION_COLUM.put("printQuantity","printCount");
  243. ASSETS_PRODUCTION_COLUM.put("archiveTime","saveFileDate");
  244. ASSETS_PRODUCTION_COLUM.put("finished","delivery");
  245. ASSETS_PRODUCTION_COLUM.put("type","productionType");
  246. ASSETS_PRODUCTION_COLUM.put("createdDatetime","createProductionDate");
  247. //财务开票字段
  248. FINANCE_INVOICE_COLUM.put("orderId","orderFundId");
  249. FINANCE_INVOICE_COLUM.put("creatorName","applyId");
  250. FINANCE_INVOICE_COLUM.put("incomeId","realFundId");
  251. FINANCE_INVOICE_COLUM.put("companyName","title");
  252. FINANCE_INVOICE_COLUM.put("companyNO","taxNo");
  253. FINANCE_INVOICE_COLUM.put("bankName","bankName");
  254. FINANCE_INVOICE_COLUM.put("bankNO","bankAccount");
  255. FINANCE_INVOICE_COLUM.put("address","bankAddress");
  256. FINANCE_INVOICE_COLUM.put("invoiceType","type");
  257. FINANCE_INVOICE_COLUM.put("project","makeItem");
  258. FINANCE_INVOICE_COLUM.put("planMoney","planAmount");
  259. FINANCE_INVOICE_COLUM.put("realMoney","realAmount");
  260. FINANCE_INVOICE_COLUM.put("taxPoint","taxRate");
  261. FINANCE_INVOICE_COLUM.put("planDate","planMakeDate");
  262. FINANCE_INVOICE_COLUM.put("realDate","realMakeDate");
  263. FINANCE_INVOICE_COLUM.put("unit","itemUnit");
  264. FINANCE_INVOICE_COLUM.put("taxAmount","taxAmount");
  265. FINANCE_INVOICE_COLUM.put("status","state");
  266. FINANCE_INVOICE_COLUM.put("reason","reason");
  267. FINANCE_INVOICE_COLUM.put("description","remark");
  268. FINANCE_INVOICE_COLUM.put("invoiceEmp","makerId");
  269. FINANCE_INVOICE_COLUM.put("ticketNo","ticketNo");
  270. }
  271. @Autowired
  272. private ProductionFundMapper productionFundMapper;
  273. @Autowired
  274. private DyoaRecordMapper dyoaRecordMapper;
  275. @Autowired
  276. private PersonalTargetMapper personalTargetMapper;
  277. @Override
  278. public Page<HisMajorOrder> hisMajorPage(HisOrderParam param) {
  279. checkCookie();
  280. pageSet(param);
  281. Page<HisMajorOrder> page = new Page<>();
  282. try {
  283. Map<String, Object> map = removeMapKey(BeanUtil.beanToMap(param));
  284. String respond = HttpKit.sendPost(HISTORY_MAJOR_ORDER_URL, map,COOKIE);
  285. JSONObject jsonObject = JSON.parseObject(respond);
  286. JSONObject data = jsonObject.getJSONObject("data");
  287. JSONArray dataArray = data.getJSONArray("data");
  288. if (CollectionUtil.isNotEmpty(dataArray)){
  289. List<HisMajorOrder> hisMajorOrders = dataArray.toJavaList(HisMajorOrder.class);
  290. page.setRecords(hisMajorOrders);
  291. page.setTotal(Long.valueOf(String.valueOf(data.get("total"))));
  292. }
  293. } catch (JSONException e) {
  294. historySystemLogin();
  295. ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"远程连接超时,请刷新页面。");
  296. } catch (Exception e) {
  297. log.error("远程调用失败.");
  298. e.printStackTrace();
  299. }
  300. return page;
  301. }
  302. @Override
  303. public String getEverCookie() {
  304. checkCookie();
  305. return COOKIE;
  306. }
  307. private void checkCookie(){
  308. if (StrUtil.isBlank(COOKIE)){
  309. historySystemLogin();
  310. }
  311. }
  312. /**
  313. * 登录原系统获取COOKIE
  314. * @return
  315. */
  316. private void historySystemLogin(){
  317. try {
  318. // 创建HttpClient对象
  319. HttpClient httpClient = new DefaultHttpClient();
  320. // 创建HttpGet请求对象
  321. HttpPost httpPost = new HttpPost(HISTORY_LOGIN_URL);
  322. // 发送请求并获取响应
  323. HttpResponse response = httpClient.execute(httpPost);
  324. // 获取cookie
  325. String cookies = Arrays.toString(response.getHeaders("Set-Cookie"));
  326. if (cookies != null) {
  327. String pattern = "(JSESSIONID)(.*?)( )";
  328. Pattern r = Pattern.compile(pattern);
  329. Matcher m = r.matcher(cookies);
  330. if (m.find()) {
  331. COOKIE = m.group(0).trim().split(";")[0];
  332. }
  333. }
  334. // 关闭连接
  335. httpClient.getConnectionManager().shutdown();
  336. } catch (Exception e) {
  337. e.printStackTrace();
  338. }
  339. }
  340. private Map<String, Object> removeMapKey(Map param) {
  341. Set set = param.keySet();
  342. for (Iterator iterator = set.iterator(); iterator.hasNext(); ) {
  343. Object obj = (Object) iterator.next();
  344. Object value = (Object) param.get(obj);
  345. if (value == null || value.equals("") || value.equals("null") || obj.toString().length() == 0) {
  346. iterator.remove();
  347. }else {
  348. if (value instanceof String){
  349. try {
  350. String xValue = new String (((String) value).getBytes("ISO8859-1"),"UTF-8");
  351. param.put(obj,xValue);
  352. } catch (UnsupportedEncodingException e) {
  353. throw new RuntimeException(e);
  354. }
  355. }
  356. }
  357. }
  358. return param;
  359. }
  360. private void pageSet(HisOrderParam param){
  361. param.setLimit(param.getSize());
  362. param.setStart((param.getCurrent()-1)*param.getLimit());
  363. }
  364. /**
  365. * 获取老系统资产订单
  366. * @param param 老系统查询参数
  367. * @return Page<HisAssetsOrder>
  368. */
  369. @Override
  370. public Page<HisAssetsOrder> hisAssetsPage(HisOrderParam param) {
  371. checkCookie();
  372. pageSet(param);
  373. Page<HisAssetsOrder> page = new Page<>();
  374. try {
  375. Map<String, Object> map = removeMapKey(BeanUtil.beanToMap(param));
  376. String respond = HttpKit.sendPost(HISTORY_ASSETS_ORDER_URL, map,COOKIE);
  377. JSONObject jsonObject = JSON.parseObject(respond);
  378. JSONObject data = jsonObject.getJSONObject("data");
  379. JSONArray dataArray = data.getJSONArray("data");
  380. if (CollectionUtil.isNotEmpty(dataArray)){
  381. List<HisAssetsOrder> hisAssetsOrders = dataArray.toJavaList(HisAssetsOrder.class);
  382. page.setRecords(hisAssetsOrders);
  383. page.setTotal(Long.valueOf(String.valueOf(data.get("total"))));
  384. }
  385. } catch (JSONException e) {
  386. historySystemLogin();
  387. ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"远程连接超时,请刷新页面。");
  388. } catch (Exception e) {
  389. log.error("远程调用失败.");
  390. e.printStackTrace();
  391. }
  392. return page;
  393. }
  394. @DSTransactional
  395. @Override
  396. public void fetchDyoaMajorOrderProduction() {
  397. List<String> majorOrderIds = dyoaHistoryMapper.selectDyoaMajorOrderIds();
  398. majorOrderIds.stream().forEach(x->{
  399. fetchAboutMajor(x);
  400. });
  401. }
  402. @Override
  403. public void fetchAboutMajor(String id) {
  404. try {
  405. //1. 获取订单信息,插入major表。
  406. Map<String, Object> dyoaMajorOrder = dyoaHistoryMapper.queryMajorOrder(id);
  407. Long mbsId = this.doCreateMajorOrder(dyoaMajorOrder);
  408. //2. 同步产品
  409. Double shouldAmount = (Double) dyoaMajorOrder.get("needPay");
  410. String code = (String) dyoaMajorOrder.get("code");
  411. String name = (String) dyoaMajorOrder.get("name");
  412. this.doCreateMajorProduction(shouldAmount,id, mbsId,code,name);
  413. } catch (NoSuchFieldException e) {
  414. throw new RuntimeException(e);
  415. } catch (IllegalAccessException e) {
  416. throw new RuntimeException(e);
  417. }
  418. }
  419. @DSTransactional
  420. @Override
  421. public void fetchDyoaPersonalOrder(){
  422. Date max = dyoaRecordService.getMaxOrderTime();
  423. List<String> personalOrderIds = dyoaHistoryMapper.getNewOrderIds(max);
  424. personalOrderIds.stream().forEach(x->{
  425. fetchAboutPersonal(x);
  426. });
  427. }
  428. @DSTransactional
  429. @Override
  430. public void fetchRealAmountClaimData() {
  431. Date max = dyoaRecordService.getMaxClaimDate();
  432. List<String> claimIds = dyoaHistoryMapper.getNewClaimRecordIds(max);
  433. claimIds.stream().forEach(x->{
  434. fetchClaimRecord(x);
  435. });
  436. //更新订单实收款金额
  437. List<OrderFund> orderTotalAmount = financeClaimService.queryOrderTotalAmount();
  438. orderFundService.updateBatchById(orderTotalAmount);
  439. //分配认领金额到产品收款表
  440. List<OrderFund> majorOrderFund = orderTotalAmount.stream().filter(x ->
  441. (x.getBusinessType().equals(MAJOR_BUSINESS.name())|| x.getBusinessType().equals(ASSET_BUSINESS.name())))
  442. .collect(Collectors.toList());
  443. majorOrderFund.stream().forEach(x->{
  444. List<ProductionFund> prods = productionFundService.list(new LambdaQueryWrapper<ProductionFund>()
  445. .eq(ProductionFund::getOrderFundId, x.getId()).select(ProductionFund::getProductionType));
  446. if (CollectionUtil.isNotEmpty(prods)){
  447. if (prods.size()>1){
  448. List<ProductionFund> noStatement = prods.stream().filter(p -> !p.getProductionType().equals(ProductionEnum.STATEMENT.name())).collect(Collectors.toList());
  449. if (noStatement.size()>1){
  450. productionFundService.update(new LambdaUpdateWrapper<ProductionFund>()
  451. .eq(ProductionFund::getOrderFundId,x.getId())
  452. .eq(ProductionFund::getProductionType,ProductionEnum.REPORT.name())
  453. .set(ProductionFund::getRealAmount,x.getRealAmount()));
  454. }else {
  455. productionFundService.update(new LambdaUpdateWrapper<ProductionFund>()
  456. .eq(ProductionFund::getOrderFundId,x.getId())
  457. .eq(ProductionFund::getProductionType,noStatement.get(0).getProductionType())
  458. .set(ProductionFund::getRealAmount,x.getRealAmount()));
  459. }
  460. }else{
  461. productionFundService.update(new LambdaUpdateWrapper<ProductionFund>()
  462. .eq(ProductionFund::getOrderFundId,x.getId()).set(ProductionFund::getRealAmount,x.getRealAmount()));
  463. }
  464. }
  465. });
  466. }
  467. private void fetchClaimRecord(String id) {
  468. try{
  469. Map<String, Object> resultMap = dyoaHistoryMapper.getNewClaimRecord(id);
  470. FinanceClaim financeClaim = new FinanceClaim();
  471. Class<FinanceClaim> fClass = FinanceClaim.class;
  472. String dyoaId = (String) resultMap.get("id");
  473. for (Map.Entry<String, String> entry : REAL_AMOUNT_CLAIM_COLUM.entrySet()){
  474. Object columValue = resultMap.get(entry.getKey());
  475. if (columValue!=null){
  476. String mbsColum = entry.getValue();
  477. Field field = fClass.getDeclaredField(mbsColum);
  478. field.setAccessible(true);
  479. switch (mbsColum){
  480. case "realFundId":
  481. Long realAmountMbsId = findRealAmountMbsId((String) columValue);
  482. if (realAmountMbsId==null){
  483. return;
  484. }
  485. field.set(financeClaim, realAmountMbsId);break;
  486. case "orderFundId":
  487. Long orderFundMbsId = findOrderFundId((String) columValue);
  488. if (orderFundMbsId==null){
  489. return;
  490. }
  491. field.set(financeClaim, orderFundMbsId);break;
  492. case "claimUserId":
  493. field.set(financeClaim,getMbsUserId((String) columValue));break;
  494. case "claimAmount":
  495. field.set(financeClaim, BigDecimal.valueOf((Double) columValue));break;
  496. // case "claimDatetime":
  497. // LocalDate value = DateUtils.parseLocalDateTime((Date) columValue);
  498. // field.set(financeClaim, (Date) columValue);break;
  499. default:
  500. field.set(financeClaim,columValue);
  501. }
  502. }
  503. }
  504. Date createdDatetime = (Date) resultMap.get("createdDatetime");
  505. financeClaim.setCreated(createdDatetime);
  506. financeClaimService.save(financeClaim);
  507. //插入同步记录表
  508. Long mbsId = financeClaim.getId();
  509. dyoaRecordService.insert(MainBusinessEnum.REAL_AMOUNT_CLAIM, mbsId, dyoaId,createdDatetime);
  510. }catch (NoSuchFieldException e) {
  511. throw new RuntimeException(e);
  512. } catch (IllegalAccessException e) {
  513. throw new RuntimeException(e);
  514. }
  515. }
  516. @DSTransactional
  517. @Override
  518. public void fetchRealAmount() {
  519. Date max = dyoaRecordService.getMaxRealAmountCreatedTime();
  520. List<String> newRealAmount = dyoaHistoryMapper.getNewRealAmount(max);
  521. newRealAmount.stream().forEach(x-> {
  522. fetchReamAmountDetail(x);
  523. });
  524. }
  525. @DSTransactional
  526. @Override
  527. public void fetchFinanceInvoiceRecord(){
  528. Date max = dyoaRecordService.getMaxFinanceInvoiceCreatedTime();
  529. List<String> newInvoice = dyoaHistoryMapper.getNewFinanceInvoice(max);
  530. newInvoice.stream().forEach(x-> {
  531. fetchFinanceInvoiceDetail(x);
  532. });
  533. }
  534. private void fetchFinanceInvoiceDetail(String id) {
  535. try{
  536. Map<String,Object> resultMap = dyoaHistoryMapper.getInvoiceInfo(id);
  537. FinanceInvoice invoice = new FinanceInvoice();
  538. Class<FinanceInvoice> fClass = FinanceInvoice.class;
  539. String dyoaId = (String) resultMap.get("id");
  540. for (Map.Entry<String, String> entry : FINANCE_INVOICE_COLUM.entrySet()){
  541. Object columValue = resultMap.get(entry.getKey());
  542. if (columValue!=null){
  543. String mbsColum = entry.getValue();
  544. Field field = fClass.getDeclaredField(mbsColum);
  545. field.setAccessible(true);
  546. switch (mbsColum){
  547. case "orderFundId":
  548. Long orderFundMbsId = findOrderFundId((String) columValue);
  549. if (orderFundMbsId==null){
  550. return;
  551. }
  552. field.set(invoice, orderFundMbsId);
  553. break;
  554. case "realFundId":
  555. Long realFundId = findRealAmountMbsId((String) columValue);
  556. if (realFundId==null){
  557. return;
  558. }
  559. field.set(invoice, realFundId);
  560. break;
  561. case "planAmount":
  562. case "realAmount":
  563. case "taxAmount":
  564. case "taxRate":
  565. field.set(invoice,BigDecimal.valueOf((Double) columValue));
  566. break;
  567. case "planMakeDate":
  568. case "realMakeDate":
  569. Timestamp ts = (Timestamp) columValue;
  570. field.set(invoice, DateUtils.dateToLocalDate(new Date(ts.getTime())));
  571. break;
  572. case "makerId":
  573. field.set(invoice,getMbsUserId((String) columValue));
  574. break;
  575. case "applyId":
  576. field.set(invoice,getMbsUserId((String) columValue));
  577. break;
  578. default:
  579. field.set(invoice,columValue);
  580. }
  581. }
  582. }
  583. String orderId = (String) resultMap.get("orderId");
  584. Long orderFundMbsId = findOrderFundId((String) orderId);
  585. Long productionFunId = getProductionFundIdByOrderFundId(orderFundMbsId);
  586. invoice.setProductionFundId(productionFunId);
  587. Date createdDatetime = (Date) resultMap.get("createdDatetime");
  588. invoice.setCreated(createdDatetime);
  589. financeInvoiceService.save(invoice);
  590. //插入同步记录表
  591. Long mbsId = invoice.getId();
  592. dyoaRecordService.insert(MainBusinessEnum.FINANCE_INVOICE, mbsId, dyoaId,createdDatetime);
  593. }catch (NoSuchFieldException e) {
  594. throw new RuntimeException(e);
  595. } catch (IllegalAccessException e) {
  596. throw new RuntimeException(e);
  597. }
  598. }
  599. private Long getProductionFundIdByOrderFundId(Long orderFundMbsId) {
  600. Map<Long, Long> collect = productionFundService.getProductionFundIdByOrderFundId().stream().collect(Collectors.toMap(ProductionFund::getOrderFundId, BaseEntity::getId));
  601. return collect.get(orderFundMbsId);
  602. }
  603. @DSTransactional
  604. @Override
  605. public void fetchAssetsOrderProduction() {
  606. List<String> assetsOrderIds = dyoaHistoryMapper.selectDyoaAssetsOrderIds();
  607. assetsOrderIds.stream().forEach(x->{
  608. fetchAboutAssets(x);
  609. });
  610. }
  611. private void fetchAboutAssets(String id) {
  612. try {
  613. //1. 获取订单信息,插入assets表。
  614. Map<String, Object> dyoaAssetsOrder = dyoaHistoryMapper.queryAssetsOrder(id);
  615. Long mbsId = this.doCreateAssetsOrder(dyoaAssetsOrder);
  616. //2. 同步产品
  617. Double shouldAmount = (Double) dyoaAssetsOrder.get("needPay");
  618. String code = (String) dyoaAssetsOrder.get("code");
  619. String name = (String) dyoaAssetsOrder.get("name");
  620. this.doCreateAssetsProduction(shouldAmount,id, mbsId,code,name);
  621. } catch (NoSuchFieldException e) {
  622. throw new RuntimeException(e);
  623. } catch (IllegalAccessException e) {
  624. throw new RuntimeException(e);
  625. }
  626. }
  627. private Long doCreateAssetsOrder(Map<String, Object> dyoaAssetsOrder) throws NoSuchFieldException, IllegalAccessException {
  628. String dyoaId = (String) dyoaAssetsOrder.get("id");
  629. String managerName = (String) dyoaAssetsOrder.get("managerName");
  630. DyoaRecord record = dyoaRecordService.getOne(new LambdaQueryWrapper<DyoaRecord>().eq(DyoaRecord::getMbsType, ASSETS_ORDER.name()).eq(DyoaRecord::getDyoaId, dyoaId));
  631. if (record != null){
  632. //更新项目负责人
  633. Long mbsOrderId = record.getMbsId();
  634. if (StrUtil.isNotEmpty(managerName)){
  635. Assets assets = assetsService.getOne(new LambdaQueryWrapper<Assets>().eq(BaseEntity::getId, mbsOrderId).select(BaseEntity::getId, Assets::getPrincipalId));
  636. if (assets.getPrincipalId()==null){
  637. assetsService.update(new LambdaUpdateWrapper<Assets>().set(Assets::getPrincipalId,getMbsUserId(managerName)).eq(BaseEntity::getId, mbsOrderId));
  638. log.info("项目负责人被更新 mbsId: {}",mbsOrderId);
  639. }
  640. }
  641. return mbsOrderId;
  642. }
  643. Assets assets = new Assets();
  644. Class<Assets> aClass = Assets.class;
  645. for (Map.Entry<String, String> entry : ASSETS_ORDER_COLUM.entrySet()){
  646. Object columValue = dyoaAssetsOrder.get(entry.getKey());
  647. if (columValue!=null){
  648. String mbsColum = entry.getValue();
  649. Field field = aClass.getDeclaredField(mbsColum);
  650. field.setAccessible(true);
  651. switch (mbsColum){
  652. case "allotType":
  653. field.set(assets,(Boolean) columValue?ASSIGN:BY_TURNS);break;
  654. case "clientManagerId":
  655. case "principalId":
  656. field.set(assets,getMbsUserId((String) columValue));break;
  657. case "departmentId":
  658. field.set(assets,getMbsDepartmentId((String) columValue));break;
  659. case "clienteleSubId":
  660. case "clienteleId":
  661. case "terminalClienteleId":
  662. field.set(assets, getCompanyId((String) columValue));break;
  663. case "terminalClienteleContactId":
  664. case "clienteleContactId":
  665. field.set(assets, getCompanyLinkmanId((String) columValue));break;
  666. default:
  667. field.set(assets,columValue);
  668. }
  669. }
  670. }
  671. assets.setCreated((Date) dyoaAssetsOrder.get("orderTime"));
  672. assetsServiceImpl.save(assets);
  673. //插入同步记录表
  674. Long mbsId = assets.getId();
  675. dyoaRecordService.insert(MainBusinessEnum.ASSETS_ORDER, mbsId, dyoaId,null);
  676. return mbsId;
  677. }
  678. private void doCreateAssetsProduction(Double shouldAmount, String id, Long mbsId, String code, String name) throws NoSuchFieldException, IllegalAccessException {
  679. //创建订单收款记录
  680. OrderFund orderFund = orderFundService.getOne(new LambdaQueryWrapper<OrderFund>().eq(OrderFund::getBusinessType, ASSET_BUSINESS.name())
  681. .eq(OrderFund::getBusinessId, mbsId).eq(OrderFund::getOrderId, code));
  682. if (orderFund==null){
  683. orderFund = new OrderFund();
  684. orderFund.setBusinessId(mbsId);
  685. orderFund.setBusinessType(ASSET_BUSINESS.name());
  686. orderFund.setOrderId(code);
  687. orderFund.setOrderName(name);
  688. orderFund.setShouldAmount(BigDecimal.valueOf(shouldAmount==null?0d:shouldAmount));
  689. orderFundService.save(orderFund);
  690. }
  691. List<HisAssetsProduction> assetsProductions = dyoaHistoryMapper.queryAssetsProduction(id);
  692. //创建产品收款记录
  693. if (CollectionUtil.isNotEmpty(assetsProductions)){
  694. for (HisAssetsProduction production :assetsProductions){
  695. if (StrUtil.isNotBlank(production.getPId())){
  696. AssetsProduction assetsProduction = new AssetsProduction();
  697. assetsProduction.setBusinessId(mbsId);
  698. for (Map.Entry<String, String> entry : ASSETS_PRODUCTION_COLUM.entrySet()){
  699. Field field = HisAssetsProduction.class.getDeclaredField(entry.getKey());
  700. field.setAccessible(true);
  701. Object value = field.get(production);
  702. if (value!=null){
  703. String mbsColum = entry.getValue();
  704. Field xFiled = AssetsProduction.class.getDeclaredField(mbsColum);
  705. xFiled.setAccessible(true);
  706. switch (mbsColum){
  707. case "productionType":
  708. String productionType = getProductionType((String) value);
  709. xFiled.set(assetsProduction, productionType);
  710. break;
  711. case "createProductionDate":
  712. Date ts = (Date) value;
  713. LocalDate value1 = DateUtils.dateToLocalDate(ts);
  714. System.out.println("value1===>" + value1);
  715. if (value1!=null){
  716. xFiled.set(assetsProduction, value1);
  717. }
  718. break;
  719. default:
  720. xFiled.set(assetsProduction,value);
  721. break;
  722. }
  723. }
  724. }
  725. if (assetsProduction.getProductionType().equals(ProductionEnum.STATEMENT.name())){
  726. assetsProduction.setProductionNo(production.getYjsReportNo());
  727. }else{
  728. assetsProduction.setProductionNo(production.getReportNo());
  729. }
  730. AssetsProduction mp = assetsProductionService.getOne(new LambdaQueryWrapper<AssetsProduction>().eq(AssetsProduction::getBusinessId, mbsId)
  731. .eq(AssetsProduction::getProductionNo, assetsProduction.getProductionNo()).eq(AssetsProduction::getProductionType, assetsProduction.getProductionType()));
  732. //插入产品记录
  733. if (mp==null){
  734. //查询有没有产品号,如果没有就不创建产品和产品收款
  735. if (StrUtil.isNotBlank(assetsProduction.getProductionNo())){
  736. assetsProductionService.save(assetsProduction);
  737. //创建产品收款记录
  738. ProductionFund productionFund = new ProductionFund();
  739. productionFund.setBusinessId(mbsId);
  740. productionFund.setBusinessType(ASSET_BUSINESS.name());
  741. productionFund.setProductionNo(assetsProduction.getProductionNo());
  742. productionFund.setProductionType(assetsProduction.getProductionType());
  743. productionFund.setOrderFundId(orderFund.getId());
  744. productionFund.setStandardAmount(production.getStandardPrice());
  745. productionFund.setProductionShouldAmount(orderFund.getShouldAmount());
  746. productionFundService.save(productionFund);
  747. }
  748. }
  749. }
  750. }
  751. }
  752. }
  753. private void fetchReamAmountDetail(String id){
  754. try{
  755. Map<String,Object> resultMap = dyoaHistoryMapper.getRealAmountInfo(id);
  756. FinanceRealFund realFund = new FinanceRealFund();
  757. Class<FinanceRealFund> fClass = FinanceRealFund.class;
  758. String dyoaId = (String) resultMap.get("id");
  759. for (Map.Entry<String, String> entry : REAL_AMOUNT_COLUM.entrySet()){
  760. Object columValue = resultMap.get(entry.getKey());
  761. if (columValue!=null){
  762. String mbsColum = entry.getValue();
  763. Field field = fClass.getDeclaredField(mbsColum);
  764. field.setAccessible(true);
  765. switch (mbsColum){
  766. case "payDatetime":
  767. field.set(realFund,DateUtils.dateToLocalDate((Date) columValue));break;
  768. case "creatorId":
  769. field.set(realFund,getMbsUserId((String) columValue));break;
  770. case "amount":
  771. field.set(realFund, BigDecimal.valueOf((Double) columValue));break;
  772. default:
  773. field.set(realFund,columValue);
  774. }
  775. }
  776. }
  777. Date createdDatetime = (Date) resultMap.get("createdDatetime");
  778. realFund.setCreated(createdDatetime);
  779. financeRealFundService.save(realFund);
  780. //插入同步记录表
  781. Long mbsId = realFund.getId();
  782. dyoaRecordService.insert(MainBusinessEnum.REAL_AMOUNT, mbsId, dyoaId,createdDatetime);
  783. }catch (NoSuchFieldException e) {
  784. throw new RuntimeException(e);
  785. } catch (IllegalAccessException e) {
  786. throw new RuntimeException(e);
  787. }
  788. }
  789. private void fetchAboutPersonal(String dyoaId) {
  790. Map<String, Object> dyoaPersonalOrder = dyoaHistoryMapper.queryPersonalOrder(dyoaId);
  791. try {
  792. DyoaRecord record = dyoaRecordService.getOne(new LambdaQueryWrapper<DyoaRecord>()
  793. .eq(DyoaRecord::getDyoaId, dyoaId).eq(DyoaRecord::getMbsType, "PERSONAL_ORDER"));
  794. Long mbsId = null;
  795. if (record!=null){
  796. mbsId = record.getMbsId();
  797. }else{
  798. //1.插入personal表
  799. Personal personal = this.doCreatePersonalOrder(dyoaPersonalOrder);
  800. //2.创建订单收款记录
  801. this.doCreatedOrderFund(personal);
  802. mbsId = personal.getId();
  803. }
  804. PersonalTarget target = new PersonalTarget();
  805. target.setPersonalId(mbsId);
  806. Object locations = dyoaPersonalOrder.get("locations");
  807. target.setLocation(locations==null?"": (String) locations);
  808. Object area = dyoaPersonalOrder.get("area");
  809. target.setAcreage(area==null?null:BigDecimal.valueOf((Double) area));
  810. Object money = dyoaPersonalOrder.get("money");
  811. target.setAmount(money==null?null:BigDecimal.valueOf((Double) money));
  812. Object price = dyoaPersonalOrder.get("price");
  813. target.setPrice(price==null?null:BigDecimal.valueOf((Double) price));
  814. personalTargetService.save(target);
  815. } catch (NoSuchFieldException e) {
  816. throw new RuntimeException(e);
  817. } catch (IllegalAccessException e) {
  818. throw new RuntimeException(e);
  819. }
  820. }
  821. private void doCreatedOrderFund(Personal personal) {
  822. //创建订单收款记录
  823. OrderFund orderFund = new OrderFund();
  824. orderFund.setBusinessId(personal.getId());
  825. orderFund.setBusinessType(PERSONAL_BUSINESS.name());
  826. orderFund.setOrderId(personal.getOrderId());
  827. orderFund.setOrderName(personal.getLocation());
  828. orderFundService.save(orderFund);
  829. }
  830. private Personal doCreatePersonalOrder(Map<String, Object> dyoaPersonalOrder) throws NoSuchFieldException, IllegalAccessException {
  831. Personal personal = new Personal();
  832. Class<Personal> mClass = Personal.class;
  833. String dyoaId = (String) dyoaPersonalOrder.get("id");
  834. for (Map.Entry<String, String> entry : PERSONAL_ORDER_COLUM.entrySet()){
  835. Object columValue = dyoaPersonalOrder.get(entry.getKey());
  836. if (columValue!=null){
  837. String mbsColum = entry.getValue();
  838. Field field = mClass.getDeclaredField(mbsColum);
  839. field.setAccessible(true);
  840. switch (mbsColum){
  841. case "purpose":
  842. case "credentials":
  843. field.set(personal,covertData((String) columValue,mbsColum));break;
  844. case "clientManagerId":
  845. case "outwardStaff":
  846. case "inwardStaff":
  847. case "pricingStaff":
  848. field.set(personal,getMbsUserId((String) columValue));break;
  849. case "loanLimit":
  850. field.set(personal, BigDecimal.valueOf((Double) columValue));break;
  851. case "loanPeriod":
  852. field.set(personal, BigDecimal.valueOf((Integer) columValue));break;
  853. case "clienteleSubId":
  854. case "clienteleId":
  855. field.set(personal, getCompanyId((String) columValue));break;
  856. case "terminalClienteleId":
  857. String terminalType = (String) dyoaPersonalOrder.get("terminalType");
  858. if ("企业".equals(terminalType)){
  859. field.set(personal, getCompanyId((String) columValue));
  860. }else {
  861. field.set(personal, getCompanyLinkmanId((String) columValue));
  862. }
  863. break;
  864. case "terminalClienteleContactId":
  865. case "clienteleContactId":
  866. field.set(personal, getCompanyLinkmanId((String) columValue));break;
  867. default:
  868. field.set(personal,columValue);
  869. }
  870. }
  871. }
  872. Date createdDatetime = (Date) dyoaPersonalOrder.get("createdDatetime");
  873. personal.setCreated(createdDatetime);
  874. personalService.save(personal);
  875. //插入同步记录表
  876. Long mbsId = personal.getId();
  877. dyoaRecordService.insert(MainBusinessEnum.PERSONAL_ORDER, mbsId, dyoaId,createdDatetime);
  878. return personal;
  879. }
  880. private static String covertData(String columValue, String mbsColum) {
  881. List<String> list = Arrays.asList(columValue.split(","));
  882. List<String> ret = new ArrayList<>();
  883. if (mbsColum.equals("purpose")){
  884. list.stream().forEach(x->{
  885. if (x.equals("住宅")){
  886. ret.add("HOUSE");
  887. }else if (x.equals("商业")){
  888. ret.add("BUSINESS");
  889. }else if (x.equals("办公")){
  890. ret.add("OFFICE");
  891. }else if (x.equals("工业")){
  892. ret.add("INDUSTRIAL");
  893. }else if (x.equals("其他")){
  894. ret.add("OTHER");
  895. }
  896. });
  897. }
  898. if (mbsColum.equals("credentials")){
  899. list.stream().forEach(x->{
  900. if (x.equals("房产证")){
  901. ret.add("HOUSE_CERTIFICATE");
  902. }else if (x.equals("国土证")){
  903. ret.add("LAND_CERTIFICATE");
  904. }else if (x.equals("不动产权证")){
  905. ret.add("IMMOVABLE_CERTIFICATE");
  906. }
  907. });
  908. }
  909. return JSON.toJSONString(ret);
  910. }
  911. private Long getCompanyId(String columValue) {
  912. List<CustomerCompany> list = customerCompanyService.list(new LambdaQueryWrapper<CustomerCompany>().eq(CustomerCompany::getName, columValue)
  913. .select(BaseEntity::getId));
  914. if (CollectionUtil.isNotEmpty(list)){
  915. return list.get(0).getId();
  916. }
  917. return null;
  918. }
  919. private Long getCompanyLinkmanId(String columValue) {
  920. List<CustomerLinkman> list = customerLinkmanService.list(new LambdaQueryWrapper<CustomerLinkman>().eq(CustomerLinkman::getName, columValue)
  921. .select(BaseEntity::getId));
  922. if (CollectionUtil.isNotEmpty(list)){
  923. return list.get(0).getId();
  924. }
  925. return null;
  926. }
  927. private String toJsonString(String columValue) {
  928. List<String> list = Arrays.asList(columValue.split(","));
  929. return JSON.toJSONString(list);
  930. }
  931. private void doCreateMajorProduction(Double shouldAmount ,String id,Long majorId,String code,String name) throws NoSuchFieldException, IllegalAccessException {
  932. //创建订单收款记录
  933. OrderFund orderFund = orderFundService.getOne(new LambdaQueryWrapper<OrderFund>().eq(OrderFund::getBusinessType, MAJOR_BUSINESS.name())
  934. .eq(OrderFund::getBusinessId, majorId).eq(OrderFund::getOrderId, code));
  935. if (orderFund==null){
  936. orderFund = new OrderFund();
  937. orderFund.setBusinessId(majorId);
  938. orderFund.setBusinessType(MAJOR_BUSINESS.name());
  939. orderFund.setOrderId(code);
  940. orderFund.setOrderName(name);
  941. orderFund.setShouldAmount(BigDecimal.valueOf(shouldAmount==null?0d:shouldAmount));
  942. orderFundService.save(orderFund);
  943. }
  944. List<HisMajorProduction> majorProductions = dyoaHistoryMapper.queryMajorProduction(id);
  945. //创建产品收款记录
  946. if (CollectionUtil.isNotEmpty(majorProductions)){
  947. for (HisMajorProduction production :majorProductions){
  948. if (StrUtil.isNotBlank(production.getPId())){
  949. MajorProduction majorProduction = new MajorProduction();
  950. majorProduction.setMajorId(majorId);
  951. for (Map.Entry<String, String> entry : MAJOR_PRODUCTION_COLUM.entrySet()){
  952. Field field = HisMajorProduction.class.getDeclaredField(entry.getKey());
  953. field.setAccessible(true);
  954. Object value = field.get(production);
  955. if (value!=null){
  956. String mbsColum = entry.getValue();
  957. Field xFiled = MajorProduction.class.getDeclaredField(mbsColum);
  958. xFiled.setAccessible(true);
  959. switch (mbsColum){
  960. case "production":
  961. String productionType = getProductionType((String) value);
  962. xFiled.set(majorProduction, productionType);
  963. break;
  964. case "delivery":
  965. xFiled.set(majorProduction,production.getConfirmTime()!=null);
  966. break;
  967. case "signatory":
  968. xFiled.set(majorProduction,getMbsUserIds((String) value));
  969. break;
  970. case "valueTiming":
  971. case "saveFileDate":
  972. case "deliveryDate":
  973. xFiled.set(majorProduction,DateUtils.dateToLocalDate((Date) value));
  974. break;
  975. case "repertoryState":
  976. String repertoryState = (String) value;
  977. xFiled.set(majorProduction,repertoryState.equals("OUT"));
  978. break;
  979. default:
  980. xFiled.set(majorProduction,value);
  981. break;
  982. }
  983. }
  984. }
  985. MajorProduction mp = majorProductionService.getOne(new LambdaQueryWrapper<MajorProduction>().eq(MajorProduction::getMajorId, majorId)
  986. .eq(MajorProduction::getReportNo, majorProduction.getReportNo()).eq(MajorProduction::getProduction, majorProduction.getProduction()));
  987. //插入产品记录
  988. if (mp==null){
  989. //查询有没有产品号,如果没有就不创建产品和产品收款
  990. if (StrUtil.isNotBlank(majorProduction.getReportNo())){
  991. majorProductionService.save(majorProduction);
  992. //创建产品收款记录
  993. ProductionFund productionFund = new ProductionFund();
  994. productionFund.setBusinessId(majorId);
  995. productionFund.setBusinessType(MAJOR_BUSINESS.name());
  996. productionFund.setProductionNo(production.getReportNo());
  997. productionFund.setProductionType(getProductionType(production.getPType()));
  998. productionFund.setOrderFundId(orderFund.getId());
  999. productionFund.setStandardAmount(production.getStandardPrice());
  1000. productionFundService.save(productionFund);
  1001. }
  1002. }
  1003. }
  1004. }
  1005. }
  1006. }
  1007. private Long findRealAmountMbsId(String columValue) {
  1008. Map<String, Long> collect = dyoaRecordService.list(new LambdaQueryWrapper<DyoaRecord>().select(DyoaRecord::getMbsId, DyoaRecord::getDyoaId)
  1009. .eq(DyoaRecord::getMbsType, REAL_AMOUNT.name())).stream().collect(Collectors.toMap(DyoaRecord::getDyoaId, DyoaRecord::getMbsId));
  1010. return collect.get(columValue);
  1011. }
  1012. private String getProductionType(String value) {
  1013. if (value.contains(ProductionEnum.REPORT.getMsg())){
  1014. return ProductionEnum.REPORT.name();
  1015. }
  1016. if (value.contains(ProductionEnum.STATEMENT.getMsg())){
  1017. return ProductionEnum.STATEMENT.name();
  1018. }
  1019. return ProductionEnum.LETTER.name();
  1020. }
  1021. private Long doCreateMajorOrder(Map<String,Object> dyMajorOrder) throws NoSuchFieldException, IllegalAccessException {
  1022. String dyoaId = (String) dyMajorOrder.get("id");
  1023. String managerName = (String) dyMajorOrder.get("managerName");
  1024. DyoaRecord record = dyoaRecordService.getOne(new LambdaQueryWrapper<DyoaRecord>().eq(DyoaRecord::getMbsType, MAJOR_ORDER.name()).eq(DyoaRecord::getDyoaId, dyoaId));
  1025. if (record != null){
  1026. //更新项目负责人
  1027. Long mbsOrderId = record.getMbsId();
  1028. if (StrUtil.isNotEmpty(managerName)){
  1029. Major major = majorServiceImpl.getOne(new LambdaQueryWrapper<Major>().eq(BaseEntity::getId, mbsOrderId).select(BaseEntity::getId, Major::getPrincipalId));
  1030. if (major.getPrincipalId()==null){
  1031. majorServiceImpl.update(new LambdaUpdateWrapper<Major>().set(Major::getPrincipalId,getMbsUserId(managerName)).eq(BaseEntity::getId, mbsOrderId));
  1032. log.info("项目负责人被更新 mbsId: {}",mbsOrderId);
  1033. }
  1034. }
  1035. return mbsOrderId;
  1036. }
  1037. Major major = new Major();
  1038. Class<Major> mClass = Major.class;
  1039. for (Map.Entry<String, String> entry : MAJOR_ORDER_COLUM.entrySet()){
  1040. Object columValue = dyMajorOrder.get(entry.getKey());
  1041. if (columValue!=null){
  1042. String mbsColum = entry.getValue();
  1043. Field field = mClass.getDeclaredField(mbsColum);
  1044. field.setAccessible(true);
  1045. switch (mbsColum){
  1046. case "allotType":
  1047. field.set(major,(Boolean) columValue?ASSIGN:BY_TURNS);break;
  1048. case "financial":
  1049. field.set(major,columValue.equals("FINANCE"));break;
  1050. case "clientManagerId":
  1051. field.set(major,getMbsUserId((String) columValue));break;
  1052. case "principalId":
  1053. field.set(major,getMbsUserId((String) columValue));break;
  1054. case "departmentId":
  1055. field.set(major,getMbsDepartmentId((String) columValue));break;
  1056. case "loanLimit":
  1057. case "loanPeriod":
  1058. field.set(major, BigDecimal.valueOf((Double) columValue));break;
  1059. case "members":
  1060. field.set(major,getMbsUserIds((String) columValue));break;
  1061. case "clienteleSubId":
  1062. case "clienteleId":
  1063. case "terminalClienteleId":
  1064. field.set(major, getCompanyId((String) columValue));break;
  1065. case "terminalClienteleContactId":
  1066. case "clienteleContactId":
  1067. field.set(major, getCompanyLinkmanId((String) columValue));break;
  1068. default:
  1069. field.set(major,columValue);
  1070. }
  1071. }
  1072. }
  1073. major.setCreated((Date) dyMajorOrder.get("createdDatetime"));
  1074. majorServiceImpl.save(major);
  1075. //插入同步记录表
  1076. Long mbsId = major.getId();
  1077. dyoaRecordService.insert(MainBusinessEnum.MAJOR_ORDER, mbsId, dyoaId,null);
  1078. return mbsId;
  1079. }
  1080. private Long getMbsUserId(String userName){
  1081. if (CollectionUtil.isEmpty(users)){
  1082. List<User> list = userService.list(new LambdaQueryWrapper<User>().select(BaseEntity::getId, User::getName));
  1083. users = list.stream().collect(Collectors.toMap(User::getName, User::getId));
  1084. }
  1085. Long clientManagerId = users.get(userName);
  1086. return clientManagerId==null?1L:clientManagerId;
  1087. }
  1088. private Long getMbsDepartmentId(String departmentName){
  1089. if (CollectionUtil.isEmpty(departments)){
  1090. List<Department> list = departmentService.list(new LambdaQueryWrapper<Department>().select(BaseEntity::getId, Department::getName));
  1091. departments = list.stream().collect(Collectors.toMap(Department::getName, Department::getId));
  1092. }
  1093. if (departmentName.equals("复审部")){
  1094. departmentName = "综合部";
  1095. }
  1096. if (departmentName.equals("土地综合部")){
  1097. departmentName = "土地规划与评估事业部";
  1098. }
  1099. if (departmentName.equals("资产事业部") ||departmentName.equals("事业部") ){
  1100. departmentName = "资产评估事业部";
  1101. }
  1102. if (departmentName.equals("资产评估1组")){
  1103. departmentName = "资产评估一组";
  1104. }
  1105. if (departmentName.equals("资产评估2组")){
  1106. departmentName = "资产评估二组";
  1107. }
  1108. if (departmentName.equals("资产评估3组")){
  1109. departmentName = "资产评估三组";
  1110. }
  1111. return departments.get(departmentName);
  1112. }
  1113. private String getMbsUserIds(String userNames){
  1114. List<Long> userIds = new ArrayList<>();
  1115. Arrays.asList(userNames.split(",")).forEach(userName -> {
  1116. Long mbsUserId = getMbsUserId(userName.replaceAll(" ",""));
  1117. userIds.add(mbsUserId);
  1118. });
  1119. return JSON.toJSONString(userIds);
  1120. }
  1121. private Long findOrderFundId(String columValue){
  1122. Map<String, Long> collect = dyoaRecordService.selectOrderFundIdByDyoaOrderId().stream().collect(Collectors.toMap(DyoaRecord::getDyoaId, DyoaRecord::getMbsId));
  1123. return collect.get(columValue);
  1124. }
  1125. private Long findProductionFundId(String columValue) {
  1126. Map<String, Long> collect = productionFundService.selectProductionFundIdByDyoaReportNo().stream().collect(Collectors.toMap(ProductionFund::getProductionNo, ProductionFund::getId));
  1127. return collect.get(columValue);
  1128. }
  1129. // private Long getMbsWorkFlows(String flowCode){
  1130. // if (CollectionUtil.isEmpty(workFlows)){
  1131. // List<WorkFlow> list = workFlowService.list(new LambdaQueryWrapper<WorkFlow>().select(BaseEntity::getId, WorkFlow::getCode));
  1132. // workFlows = list.stream().collect(Collectors.toMap(WorkFlow::getCode, WorkFlow::getId));
  1133. // }
  1134. // return workFlows.get(flowCode);
  1135. // }
  1136. //
  1137. // private Long getMbsWorkNodes(String nodeName){
  1138. // if (CollectionUtil.isEmpty(majorBusinessNodes)){
  1139. // List<WorkNode> list = workNodeService.list(new LambdaQueryWrapper<WorkNode>().select(BaseEntity::getId, WorkNode::getName)
  1140. // .eq(WorkNode::getFlowId,getMbsWorkFlows(MAJOR_BUSINESS.name())));
  1141. // majorBusinessNodes = list.stream().collect(Collectors.toMap(WorkNode::getName, WorkNode::getId));
  1142. // }
  1143. // return majorBusinessNodes.get(nodeName);
  1144. // }
  1145. // private Long doCreateMajorInstanceNode(Long businessId,String dyoaNodeName,List<MajorProduction> productions){
  1146. // String businessSubId = null;
  1147. // String businessMinId = null;
  1148. // if (CollectionUtil.isNotEmpty(productions)){
  1149. // List<MajorProduction> statement = productions.stream().filter(x -> x.getProduction().equals(ProductionEnum.STATEMENT.name())).collect(Collectors.toList());
  1150. // if (CollectionUtil.isNotEmpty(statement)){
  1151. // businessSubId = statement.get(0).getReportNo();
  1152. // }
  1153. // List<MajorProduction> report = productions.stream().filter(x -> x.getProduction().equals(ProductionEnum.REPORT.name())).collect(Collectors.toList());
  1154. // if (CollectionUtil.isNotEmpty(report)){
  1155. // businessMinId = report.get(0).getReportNo();
  1156. // }
  1157. // List<MajorProduction> letter = productions.stream().filter(x -> x.getProduction().equals(ProductionEnum.LETTER.name())).collect(Collectors.toList());
  1158. // if (CollectionUtil.isNotEmpty(letter)){
  1159. // businessMinId = letter.get(0).getReportNo();
  1160. // }
  1161. //
  1162. // }
  1163. // Long nodeId = getMbsWorkNodes(dyoaNodeName);
  1164. // Long flowId = getMbsWorkFlows(MAJOR_BUSINESS.name());
  1165. // WorkFlowNodeInstance instance = new WorkFlowNodeInstance();
  1166. // instance.setFlowId(flowId);
  1167. // instance.setBusinessId(businessId);
  1168. // instance.setBusinessSubId(businessSubId);
  1169. // instance.setBusinessMinId(businessMinId);
  1170. // instance.setNodeId(nodeId);
  1171. // instance.setBusinessType(MAJOR_BUSINESS.name());
  1172. // instance.setSequence(0);
  1173. // instance.setState(PENDING.name());
  1174. // workFlowNodeInstanceService.add(instance);
  1175. // return instance.getId();
  1176. // }
  1177. // private void doCreateNodeTask(Long instanceNodeId, String dyoaNodeName,String dyoaHandlerName) {
  1178. // Long nodeId = getMbsWorkNodes(dyoaNodeName);
  1179. // WorkNodeTask task = workNodeTaskService.getOne(new LambdaQueryWrapper<WorkNodeTask>().eq(WorkNodeTask::getNodeId, nodeId)
  1180. // .eq(WorkNodeTask::getVersion, LATEST.name()).select(BaseEntity::getId));
  1181. // WorkTaskRecord workTaskRecord = new WorkTaskRecord();
  1182. // workTaskRecord.setInstanceId(instanceNodeId);
  1183. // workTaskRecord.setTaskId(task.getId());
  1184. // workTaskRecord.setHandlerId(getMbsUserId(dyoaHandlerName));
  1185. // workTaskRecordService.save(workTaskRecord);
  1186. // }
  1187. // public List<MajorProduction> doCreateMajorTarget(String targetType, String id,Long majorId) throws NoSuchFieldException, IllegalAccessException {
  1188. // List<MajorTarget> mts = new ArrayList<>();
  1189. // List<MajorProduction> mps = new ArrayList<>();
  1190. // if ("土地".equals(targetType)){
  1191. // List<HisMajorTarget> majorLandTarget = dyoaHistoryMapper.queryMajorLandTarget(id);
  1192. // Map<String, List<HisMajorTarget>> collect = majorLandTarget.stream()
  1193. // .collect(Collectors.groupingBy(HisMajorTarget::getTId));
  1194. // for (Map.Entry<String, List<HisMajorTarget>> target : collect.entrySet()){
  1195. // MajorTarget majorTarget = new MajorTarget();
  1196. // majorTarget.setTargetType("土地");
  1197. // majorTarget.setMajorId(majorId);
  1198. // for (Map.Entry<String, String> entry : MAJOR_TARGET_LAND_COLUM.entrySet()){
  1199. // Field field = HisMajorTarget.class.getDeclaredField(entry.getKey());
  1200. // field.setAccessible(true);
  1201. // Object value = field.get(target.getValue().get(0));
  1202. // if (value!=null){
  1203. // String mbsColum = entry.getValue();
  1204. // Field xFiled = MajorTarget.class.getDeclaredField(mbsColum);
  1205. // xFiled.setAccessible(true);
  1206. // switch (mbsColum){
  1207. // case "principalId":
  1208. // xFiled.set(majorTarget,getMbsUserId((String) value));
  1209. // break;
  1210. // case "siteIds":
  1211. // xFiled.set(majorTarget,getMbsUserIds((String) value));
  1212. // break;
  1213. // case "evaluateMethods":
  1214. // String methods = (String) value;
  1215. // xFiled.set(majorTarget,JSON.toJSONString(Arrays.asList(methods.split(","))));
  1216. // break;
  1217. // default:
  1218. // xFiled.set(majorTarget,value);
  1219. // }
  1220. // }
  1221. // }
  1222. // mts.add(majorTarget);
  1223. // //是否有产品
  1224. // for (HisMajorTarget production :target.getValue()){
  1225. // if (StrUtil.isNotBlank(production.getPId())){
  1226. // MajorProduction majorProduction = new MajorProduction();
  1227. // majorProduction.setMajorId(majorId);
  1228. // for (Map.Entry<String, String> entry : MAJOR_PRODUCTION_COLUM.entrySet()){
  1229. // Field field = HisMajorTarget.class.getDeclaredField(entry.getKey());
  1230. // field.setAccessible(true);
  1231. // Object value = field.get(production);
  1232. // if (value!=null){
  1233. // String mbsColum = entry.getValue();
  1234. // Field xFiled = MajorProduction.class.getDeclaredField(mbsColum);
  1235. // xFiled.setAccessible(true);
  1236. // switch (mbsColum){
  1237. // case "production":
  1238. // String productionType = getProductionType((String) value);
  1239. // xFiled.set(majorProduction, productionType);
  1240. // if (ProductionEnum.STATEMENT.name().equals(productionType)){
  1241. // majorTarget.setStatementNo(production.getReportNo());
  1242. // }
  1243. // if (ProductionEnum.REPORT.name().equals(productionType)){
  1244. // majorTarget.setReportNo(production.getReportNo());
  1245. // }
  1246. // if (ProductionEnum.LETTER.name().equals(productionType)){
  1247. // majorTarget.setLetterNo(production.getReportNo());
  1248. // }
  1249. //
  1250. // break;
  1251. // case "delivery":
  1252. // xFiled.set(majorProduction,production.getConfirmTime()!=null);
  1253. // break;
  1254. // case "signatory":
  1255. // xFiled.set(majorProduction,getMbsUserIds((String) value));
  1256. // break;
  1257. // case "valueTiming":
  1258. // case "saveFileDate":
  1259. // case "deliveryDate":
  1260. // xFiled.set(majorProduction,DateUtils.dateToLocalDate((Date) value));
  1261. // break;
  1262. // case "repertoryState":
  1263. // String repertoryState = (String) value;
  1264. // xFiled.set(majorProduction,repertoryState.equals("OUT"));
  1265. // break;
  1266. // default:
  1267. // xFiled.set(majorProduction,value);
  1268. // break;
  1269. // }
  1270. // }
  1271. // }
  1272. // mps.add(majorProduction);
  1273. // }
  1274. // }
  1275. //
  1276. // }
  1277. //
  1278. // }
  1279. // if ("房地产".equals(targetType)){
  1280. // List<HisMajorTarget> majorHouseTarget = dyoaHistoryMapper.queryMajorHouseTarget(id);
  1281. // Map<String, List<HisMajorTarget>> collect = majorHouseTarget.stream()
  1282. // .collect(Collectors.groupingBy(HisMajorTarget::getTId));
  1283. // for (Map.Entry<String, List<HisMajorTarget>> target : collect.entrySet()){
  1284. // MajorTarget majorTarget = new MajorTarget();
  1285. // majorTarget.setTargetType("房地产");
  1286. // majorTarget.setMajorId(majorId);
  1287. // for (Map.Entry<String, String> entry : MAJOR_TARGET_HOUSE_COLUM.entrySet()){
  1288. // Field field = HisMajorTarget.class.getDeclaredField(entry.getKey());
  1289. // field.setAccessible(true);
  1290. // Object value = field.get(target.getValue().get(0));
  1291. // if (value!=null){
  1292. // String mbsColum = entry.getValue();
  1293. // Field xFiled = MajorTarget.class.getDeclaredField(mbsColum);
  1294. // xFiled.setAccessible(true);
  1295. // switch (mbsColum){
  1296. // case "principalId":
  1297. // xFiled.set(majorTarget,getMbsUserId((String) value));
  1298. // break;
  1299. // case "siteIds":
  1300. // xFiled.set(majorTarget,getMbsUserIds((String) value));
  1301. // break;
  1302. // case "evaluateMethods":
  1303. // case "housePurpose":
  1304. // String methods = (String) value;
  1305. // xFiled.set(majorTarget,JSON.toJSONString(Arrays.asList(methods.split(","))));
  1306. // break;
  1307. // default:
  1308. // xFiled.set(majorTarget,value);
  1309. // }
  1310. // }
  1311. // }
  1312. // mts.add(majorTarget);
  1313. // //是否有产品
  1314. // for (HisMajorTarget production :target.getValue()){
  1315. // if (StrUtil.isNotBlank(production.getPId())){
  1316. // MajorProduction majorProduction = new MajorProduction();
  1317. // majorProduction.setMajorId(majorId);
  1318. // for (Map.Entry<String, String> entry : MAJOR_PRODUCTION_COLUM.entrySet()){
  1319. // Field field = HisMajorTarget.class.getDeclaredField(entry.getKey());
  1320. // field.setAccessible(true);
  1321. // Object value = field.get(production);
  1322. // if (value!=null){
  1323. // String mbsColum = entry.getValue();
  1324. // Field xFiled = MajorProduction.class.getDeclaredField(mbsColum);
  1325. // xFiled.setAccessible(true);
  1326. // switch (mbsColum){
  1327. // case "production":
  1328. // String productionType = getProductionType((String) value);
  1329. // xFiled.set(majorProduction, productionType);
  1330. // if (ProductionEnum.STATEMENT.name().equals(productionType)){
  1331. // majorTarget.setStatementNo(production.getReportNo());
  1332. // }
  1333. // if (ProductionEnum.REPORT.name().equals(productionType)){
  1334. // majorTarget.setReportNo(production.getReportNo());
  1335. // }
  1336. // if (ProductionEnum.LETTER.name().equals(productionType)){
  1337. // majorTarget.setLetterNo(production.getReportNo());
  1338. // }
  1339. //
  1340. // break;
  1341. // case "delivery":
  1342. // xFiled.set(majorProduction,production.getConfirmTime()!=null);
  1343. // break;
  1344. // case "signatory":
  1345. // xFiled.set(majorProduction,getMbsUserIds((String) value));
  1346. // break;
  1347. // case "valueTiming":
  1348. // case "saveFileDate":
  1349. // case "deliveryDate":
  1350. // xFiled.set(majorProduction,DateUtils.dateToLocalDate((Date) value));
  1351. // break;
  1352. // case "repertoryState":
  1353. // String repertoryState = (String) value;
  1354. // xFiled.set(majorProduction,repertoryState.equals("OUT"));
  1355. // break;
  1356. // default:
  1357. // xFiled.set(majorProduction,value);
  1358. // break;
  1359. // }
  1360. // }
  1361. // }
  1362. // mps.add(majorProduction);
  1363. // }
  1364. // }
  1365. //
  1366. // }
  1367. // }
  1368. // if (CollectionUtil.isNotEmpty(mts)){
  1369. // majorTargetService.saveBatch(mts);
  1370. // }
  1371. // if (CollectionUtil.isNotEmpty(mps)){
  1372. // majorProductionService.saveBatch(mps);
  1373. // //更新报价反馈
  1374. // List<PriceFeedbackDTO> feedbackDTOS = new ArrayList<>();
  1375. // String statementNo = null;
  1376. // for (MajorProduction majorProduction : mps){
  1377. // if (majorProduction.getProduction().equals(ProductionEnum.STATEMENT.name())){
  1378. // PriceFeedbackDTO feedbackDTO = new PriceFeedbackDTO();
  1379. // feedbackDTO.setProduction(Arrays.asList(ProductionEnum.STATEMENT));
  1380. // feedbackDTO.setMajorId(majorId);
  1381. // feedbackDTO.setPrinting(majorProduction.getPrintTimes());
  1382. // statementNo = majorProduction.getReportNo();
  1383. // feedbackDTOS.add(feedbackDTO);
  1384. // }
  1385. // if (majorProduction.getProduction().equals(ProductionEnum.REPORT.name())){
  1386. // PriceFeedbackDTO feedbackDTO = new PriceFeedbackDTO();
  1387. // List<ProductionEnum> p = new ArrayList<>();
  1388. // if (StrUtil.isNotEmpty(statementNo)){
  1389. // p.add(ProductionEnum.STATEMENT);
  1390. // }
  1391. // p.add(ProductionEnum.REPORT);
  1392. // feedbackDTO.setProduction(p);
  1393. // feedbackDTO.setMajorId(majorId);
  1394. // feedbackDTO.setPrinting(majorProduction.getPrintTimes());
  1395. // feedbackDTO.setReportNo(statementNo);
  1396. // feedbackDTOS.add(feedbackDTO);
  1397. // }
  1398. // if (majorProduction.getProduction().equals(ProductionEnum.LETTER.name())){
  1399. // PriceFeedbackDTO feedbackDTO = new PriceFeedbackDTO();
  1400. // List<ProductionEnum> p = new ArrayList<>();
  1401. // if (StrUtil.isNotEmpty(statementNo)){
  1402. // p.add(ProductionEnum.STATEMENT);
  1403. // }
  1404. // p.add(ProductionEnum.REPORT);
  1405. // feedbackDTO.setProduction(p);
  1406. // feedbackDTO.setMajorId(majorId);
  1407. // feedbackDTO.setPrinting(majorProduction.getPrintTimes());
  1408. // feedbackDTO.setReportNo(statementNo);
  1409. // feedbackDTOS.add(feedbackDTO);
  1410. // }
  1411. // }
  1412. // if (CollectionUtil.isNotEmpty(feedbackDTOS)){
  1413. // majorServiceImpl.update(new LambdaUpdateWrapper<Major>().set(Major::getFeedbackInfo,JSON.toJSONString(feedbackDTOS))
  1414. // .eq(BaseEntity::getId,majorId));
  1415. // }
  1416. // return mps;
  1417. // }
  1418. // return null;
  1419. // }
  1420. }