TCntrnoServiceImpl.java 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. package com.ruoyi.shipping.service.impl;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.math.BigDecimal;
  5. import java.text.ParseException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.*;
  8. import java.util.concurrent.ConcurrentHashMap;
  9. import java.util.function.Function;
  10. import java.util.function.Predicate;
  11. import java.util.stream.Collectors;
  12. import com.alibaba.fastjson.JSONArray;
  13. import com.alibaba.fastjson.JSONObject;
  14. import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  15. import com.ruoyi.common.constant.UserConstants;
  16. import com.ruoyi.common.core.domain.AjaxResult;
  17. import com.ruoyi.common.core.domain.entity.SysDictData;
  18. import com.ruoyi.common.core.domain.model.LoginUser;
  19. import com.ruoyi.common.utils.DateUtils;
  20. import com.ruoyi.common.utils.SecurityUtils;
  21. import com.ruoyi.common.utils.StringUtils;
  22. import com.ruoyi.shipping.domain.*;
  23. import com.ruoyi.shipping.excel.*;
  24. import com.ruoyi.shipping.mapper.*;
  25. import org.apache.poi.hssf.usermodel.HSSFDateUtil;
  26. import org.apache.poi.openxml4j.util.ZipSecureFile;
  27. import org.apache.poi.ss.usermodel.*;
  28. import org.apache.poi.ss.util.CellReference;
  29. import org.apache.poi.xssf.streaming.SXSSFWorkbook;
  30. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  31. import org.springframework.beans.BeanUtils;
  32. import org.springframework.beans.factory.annotation.Autowired;
  33. import org.springframework.stereotype.Service;
  34. import com.ruoyi.shipping.service.ITCntrnoService;
  35. import org.springframework.transaction.annotation.Transactional;
  36. import org.springframework.transaction.interceptor.TransactionAspectSupport;
  37. import org.springframework.util.ObjectUtils;
  38. import org.springframework.web.multipart.MultipartFile;
  39. import com.ruoyi.system.mapper.SysDictDataMapper;
  40. import static com.ruoyi.common.utils.poi.Excel.filter;
  41. /**
  42. * 集装箱号Service业务层处理
  43. *
  44. * @author ruoyi
  45. * @date 2021-03-22
  46. */
  47. @Service
  48. public class TCntrnoServiceImpl implements ITCntrnoService {
  49. @Autowired
  50. private TCntrnoMapper tCntrnoMapper;
  51. @Autowired
  52. private TCntrtrackingMapper tCntrtrackingMapper;
  53. @Autowired
  54. private TCntrMapper tCntrMapper;
  55. @Autowired
  56. private SysDictDataMapper sysDictDataMapper;
  57. @Autowired
  58. private TAddressMapper tAddressMapper;
  59. @Autowired
  60. private TConditionAccessoryMapper tConditionAccessoryMapper;
  61. /**
  62. * 查询集装箱号
  63. *
  64. * @param fId 集装箱号ID
  65. * @return 集装箱号
  66. */
  67. @Override
  68. public TCntrno selectTCntrnoById(Long fId) {
  69. return tCntrnoMapper.selectTCntrnoById(fId);
  70. }
  71. /**
  72. * 查询集装箱号列表
  73. *
  74. * @param tCntrno 集装箱号
  75. * @return 集装箱号
  76. */
  77. @Override
  78. public List<TCntrno> selectTCntrnoList(TCntrno tCntrno) {
  79. return tCntrnoMapper.selectTCntrnoList(tCntrno);
  80. }
  81. /**
  82. * 新增集装箱号
  83. *
  84. * @param tCntrno 集装箱号
  85. * @return 结果
  86. */
  87. @Override
  88. public int insertTCntrno(TCntrno tCntrno) {
  89. tCntrno.setCreateTime(DateUtils.getNowDate());
  90. tCntrno.setCreateBy(SecurityUtils.getUsername());
  91. tCntrno.setfUpdatetime(DateUtils.getNowDate());
  92. tCntrno.setfStatus("T");
  93. return tCntrnoMapper.insertTCntrno(tCntrno);
  94. }
  95. /**
  96. * 修改集装箱号
  97. *
  98. * @param tCntrno 集装箱号
  99. * @return 结果
  100. */
  101. @Override
  102. @Transactional
  103. public int updateTCntrno(List<TCntrno> tCntrno) {
  104. int update = 0;
  105. if (CollectionUtils.isNotEmpty(tCntrno)) {
  106. for (TCntrno cntrno : tCntrno) {
  107. String remark = cntrno.getRemark();
  108. cntrno.setUpdateTime(DateUtils.getNowDate());
  109. cntrno.setUpdateBy(SecurityUtils.getUsername());
  110. //最新时间
  111. if (cntrno.getFoldtime() == null) {
  112. cntrno.setfUpdatetime(DateUtils.getNowDate());
  113. } else {
  114. cntrno.setfUpdatetime(cntrno.getFoldtime());
  115. }
  116. //调入地点
  117. if (StringUtils.isNotEmpty(cntrno.getFoldSite())) {
  118. cntrno.setfUpdateaddress(cntrno.getFoldSite());
  119. }
  120. //调入空重
  121. if (StringUtils.isNotEmpty(cntrno.getFoldFUpdateef())) {
  122. cntrno.setfUpdateef(cntrno.getFoldFUpdateef());
  123. }
  124. //调入状态
  125. if (StringUtils.isNotEmpty(cntrno.getFoldFCntrstatus())) {
  126. cntrno.setfCntrstatus(cntrno.getFoldFCntrstatus());
  127. }
  128. if (StringUtils.isNotEmpty(remark)) {
  129. cntrno.setRemark(null);
  130. }
  131. //更改t_cntro表信息
  132. update = tCntrnoMapper.updateTCntrno((cntrno));
  133. //保存信息
  134. TCntrno cntrnoById = tCntrnoMapper.selectTCntrnoById(cntrno.getfId());
  135. if (cntrnoById.getfStatus().equals("T") || cntrnoById.getfStatus().equals("正常")) {
  136. cntrnoById.setfStatus("T");
  137. } else {
  138. cntrnoById.setfStatus("F");
  139. }
  140. if (StringUtils.isNotEmpty(cntrno.getfMblno())) {//提单号
  141. cntrnoById.setfMblno(cntrno.getfMblno());
  142. }
  143. if (StringUtils.isNotEmpty(cntrno.getfVoy())) {//航次
  144. cntrnoById.setfVoy(cntrno.getfVoy());
  145. }
  146. if (StringUtils.isNotEmpty(cntrno.getfVsl())) {//船名
  147. cntrnoById.setfVsl(cntrno.getfVsl());
  148. }
  149. if (StringUtils.isNotEmpty(remark)) {
  150. cntrnoById.setRemark(remark);
  151. }
  152. TCntrtracking setfield = setfield(cntrnoById);
  153. tCntrtrackingMapper.insertTCntrtracking(setfield);
  154. if (CollectionUtils.isNotEmpty(cntrno.getAccessoryList())) {
  155. for (TConditionAccessory tConditionAccessory : cntrno.getAccessoryList()) {
  156. tConditionAccessory.setfOrgId(10L);
  157. tConditionAccessory.setfPid(setfield.getfId());
  158. tConditionAccessory.setCreateBy(SecurityUtils.getUsername());
  159. tConditionAccessory.setCreateTime(DateUtils.getNowDate());
  160. tConditionAccessoryMapper.insertTConditionAccessory(tConditionAccessory);
  161. }
  162. }
  163. }
  164. }
  165. return update;
  166. }
  167. @Override
  168. @Transactional
  169. public AjaxResult updateAirForceStation(List<TCntrno> tCntrno) {
  170. int update = 0;
  171. if (CollectionUtils.isNotEmpty(tCntrno)) {
  172. for (TCntrno cntrno : tCntrno) {
  173. String remark = cntrno.getRemark();
  174. cntrno.setUpdateTime(DateUtils.getNowDate());
  175. cntrno.setUpdateBy(SecurityUtils.getUsername());
  176. TCntrno cnTrNoByfNo = tCntrnoMapper.selectTCnTrNoByfNo(cntrno.getfNo());
  177. if (cnTrNoByfNo == null){
  178. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  179. return AjaxResult.error("箱号:"+cntrno.getfNo()+"系统中不存在请维护");
  180. }else {
  181. cntrno.setfId(cnTrNoByfNo.getfId());
  182. //更改t_cntro表信息
  183. update = tCntrnoMapper.updateTCntrno((cntrno));
  184. }
  185. //保存历史信息
  186. TCntrno cntrnoById = tCntrnoMapper.selectTCntrnoById(cntrno.getfId());
  187. if (cntrnoById.getfStatus().equals("T") || cntrnoById.getfStatus().equals("正常")) {
  188. cntrnoById.setfStatus("T");
  189. } else {
  190. cntrnoById.setfStatus("F");
  191. }
  192. if (StringUtils.isNotEmpty(cntrno.getfMblno())) {//提单号
  193. cntrnoById.setfMblno(cntrno.getfMblno());
  194. }
  195. if (StringUtils.isNotEmpty(cntrno.getfVoy())) {//航次
  196. cntrnoById.setfVoy(cntrno.getfVoy());
  197. }
  198. if (StringUtils.isNotEmpty(cntrno.getfVsl())) {//船名
  199. cntrnoById.setfVsl(cntrno.getfVsl());
  200. }
  201. if (StringUtils.isNotEmpty(remark)) {
  202. cntrnoById.setRemark(remark);
  203. }
  204. TCntrtracking setfield = setfield(cntrnoById);
  205. update = tCntrtrackingMapper.insertTCntrtracking(setfield);
  206. }
  207. }
  208. if (update <= 0 ){
  209. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  210. return AjaxResult.error("保存场站信息失败");
  211. }
  212. return AjaxResult.success();
  213. }
  214. @Override
  215. @Transactional
  216. public int updateTCntrnoMessage(TCntrno tCntrno) {
  217. tCntrno.setUpdateTime(DateUtils.getNowDate());
  218. tCntrno.setUpdateBy(SecurityUtils.getUsername());
  219. tCntrno.setfUpdatetime(DateUtils.getNowDate());
  220. if (tCntrno.getfStatus().equals("T") || tCntrno.getfStatus().equals("正常")) {
  221. tCntrno.setfStatus("T");
  222. } else {
  223. tCntrno.setfStatus("F");
  224. }
  225. TCntrtracking setfield = setfield(tCntrno);
  226. tCntrtrackingMapper.insertTCntrtracking(setfield);
  227. //更改t_cntro表信息
  228. return tCntrnoMapper.updateTCntrno((tCntrno));
  229. }
  230. /**
  231. * 批量删除集装箱号
  232. *
  233. * @param fIds 需要删除的集装箱号ID
  234. * @return 结果
  235. */
  236. @Override
  237. public int deleteTCntrnoByIds(Long[] fIds) {
  238. return tCntrnoMapper.deleteTCntrnoByIds(fIds);
  239. }
  240. /**
  241. * 删除集装箱号信息
  242. *
  243. * @param fId 集装箱号ID
  244. * @return 结果
  245. */
  246. @Override
  247. public int deleteTCntrnoById(Long fId) {
  248. return tCntrnoMapper.deleteTCntrnoById(fId);
  249. }
  250. /**
  251. * 批量更新数据状态将正常状态改为停用
  252. *
  253. * @param fIds
  254. * @return
  255. */
  256. @Override
  257. public int updateTcntrnoStatus(Long[] fIds) {
  258. return tCntrnoMapper.updateTcntrnoStatus(fIds);
  259. }
  260. @Override
  261. public List<TCntrno> selectTcntrnoMessage(TCntrno tCntrno) {
  262. return tCntrnoMapper.selectTcntrnoMessage(tCntrno, null, null, null, null, null);
  263. }
  264. @Override
  265. public List<Map<String, Object>> getTCntrnoMessage(TCntrno tCntrno,List<String> list ) {
  266. List<Map<String, Object>> mapList = new ArrayList<>();
  267. StringBuffer stringBuffer = new StringBuffer();//查类型数据
  268. StringBuffer standBuffer = new StringBuffer();//查空重
  269. /*StringBuffer bareWeightBuffer = new StringBuffer();//查好坏*/
  270. String sql = null;//查类型数据
  271. String stand = null;//查空重
  272. /*String bareWeight = null;//查好坏*/
  273. if (CollectionUtils.isNotEmpty(list)) {
  274. for (String s : list) {
  275. stringBuffer.append("MAX( CASE WHEN tt.f_no = '" + s);
  276. stringBuffer.append("' THEN tt.typeidCount ELSE 0 END ) AS '" + s + "',");
  277. standBuffer.append("MAX( CASE WHEN a.typeName ='"+s+"' AND a.dict_label = '空'");
  278. standBuffer.append("THEN a.efCount ELSE 0 END ) AS '" + s + "空',");
  279. standBuffer.append("MAX( CASE WHEN a.typeName ='"+s+"' AND a.dict_label = '重'");
  280. standBuffer.append("THEN a.efCount ELSE 0 END ) AS '" + s + "重',");
  281. /*bareWeightBuffer.append("MAX( CASE WHEN b.typeName ='"+s+"' AND b.dict_label = '好'");
  282. bareWeightBuffer.append("THEN b.statusCount ELSE 0 END ) AS '" + s + "好',");
  283. bareWeightBuffer.append("MAX( CASE WHEN b.typeName ='"+s+"' AND b.dict_label = '坏'");
  284. bareWeightBuffer.append("THEN b.statusCount ELSE 0 END ) AS '" + s + "坏',");*/
  285. }
  286. sql = stringBuffer.subSequence(0, stringBuffer.length() - 1).toString();
  287. stand = standBuffer.subSequence(0, standBuffer.length() - 1).toString();
  288. /*bareWeight = bareWeightBuffer.subSequence(0, bareWeightBuffer.length() - 1).toString();*/
  289. mapList = tCntrnoMapper.getTCntrnoMessage(sql,stand,tCntrno);
  290. }
  291. return mapList;
  292. }
  293. @Override
  294. public List<TCntrno> getTCntrnoDistribute(TCntrno tCntrno) {
  295. //箱类型不为空查箱类型id
  296. String address = null;//地点
  297. String typeidName = null;//箱类型
  298. String cntrstatusName = null;//箱状态
  299. String updateEFName = null;//空重
  300. if (StringUtils.isNotEmpty(tCntrno.getAddressName())) {
  301. address = tCntrno.getAddressName();
  302. }else {
  303. tCntrno.setfUpdateaddress("0");
  304. }
  305. if (StringUtils.isNotEmpty(tCntrno.getTypeidName())) {
  306. typeidName = tCntrno.getTypeidName();
  307. }
  308. //箱状态不为空查箱状态
  309. if (StringUtils.isNotEmpty(tCntrno.getCntrstatusName())) {
  310. cntrstatusName = tCntrno.getCntrstatusName();
  311. }
  312. //箱空重部位空查空重
  313. if (StringUtils.isNotEmpty(tCntrno.getUpdateEFName())) {
  314. updateEFName = tCntrno.getUpdateEFName();
  315. }
  316. return tCntrnoMapper.selectTcntrnoMessage(tCntrno, address, typeidName, cntrstatusName, updateEFName, tCntrno.getCntrsize());
  317. }
  318. @Override
  319. public List<String> getTCntrnoChange(TCntrno tCntrno) {
  320. List<String> key = new ArrayList<>();
  321. key.add("地点");
  322. /*List<String> list = tCntrMapper.selectTCntrFNo();
  323. List<String> mapList = new ArrayList<>();
  324. if (CollectionUtils.isNotEmpty(list)){
  325. for (String s : list) {
  326. mapList.add(s);
  327. mapList.add(s+"空");
  328. mapList.add(s+"重");
  329. *//* mapList.add(s+"好");
  330. mapList.add(s+"坏");*//*
  331. }
  332. }
  333. list.addAll(mapList);
  334. Collections.sort(list);*/
  335. key.add("20GP");
  336. key.add("20HC");
  337. key.add("20GP空");
  338. key.add("20GP重");
  339. key.add("20HC空");
  340. key.add("20HC重");
  341. return key;
  342. }
  343. @Override
  344. public String selectTCntrnoFNo(TCntrno tCntrno) {
  345. TCntrno cntrno = tCntrnoMapper.selectTCntrnoFNo(tCntrno);
  346. if (StringUtils.isNotNull(cntrno) && !cntrno.getfId().equals(tCntrno.getfId())) {
  347. return UserConstants.NOT_UNIQUE;
  348. }
  349. return UserConstants.UNIQUE;
  350. }
  351. /**
  352. * 后续维护
  353. *
  354. * @param fileName 更新箱信息数据列表
  355. * @return
  356. */
  357. @Override
  358. public AjaxResult importUpdateDataTcntrnoExcel(MultipartFile fileName) {
  359. return null;
  360. }
  361. /**
  362. * 后续维护
  363. *
  364. * @param fileName 更新箱信息数据列表
  365. * @return
  366. */
  367. @Override
  368. public AjaxResult importTcntrnoDataExcel(MultipartFile fileName) {
  369. return null;
  370. }
  371. @Override
  372. public AjaxResult importCreateCompanyMsg(MultipartFile file) throws Exception {
  373. List<TCntrnoExcel> fleetCompanyMsgs = new ArrayList<>();
  374. InputStream inputStream = null;
  375. try {
  376. inputStream = file.getInputStream();
  377. String originalFilename = file.getOriginalFilename();
  378. Workbook workbook = null;
  379. if (originalFilename.endsWith("xls")) {
  380. workbook = WorkbookFactory.create(inputStream);
  381. } else if (originalFilename.endsWith("xlsx")) {
  382. workbook = new XSSFWorkbook(inputStream);
  383. }
  384. Sheet sheet = workbook.getSheetAt(0);
  385. int line = 0;
  386. for (Row rows : sheet) {
  387. line++;
  388. if (rows.getRowNum() == 0) {
  389. continue;
  390. }
  391. TCntrnoExcel companyMsg = new TCntrnoExcel();
  392. for (int a = 0; a <= rows.getPhysicalNumberOfCells(); a++) {
  393. Cell cell = rows.getCell(a);
  394. if (cell == null){
  395. continue;
  396. }
  397. String value = filter(sheet.getRow(0), CellReference.convertNumToColString(cell.getColumnIndex()));
  398. switch (value) {
  399. case "箱号":
  400. //设置单元格类型
  401. cell.setCellType(CellType.STRING);
  402. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  403. /*return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱号");*/
  404. break;
  405. }
  406. companyMsg.setfNo(cell.getStringCellValue());
  407. break;
  408. case "箱类型":
  409. //设置单元格类型
  410. cell.setCellType(CellType.STRING);
  411. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  412. /*return AjaxResult.error("Excel箱信息数据第" + line + "箱类型");*/
  413. break;
  414. }
  415. companyMsg.setTypeidName(cell.getStringCellValue());
  416. if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
  417. Long fId = tCntrMapper.selectRcntrFId(companyMsg.getTypeidName());
  418. companyMsg.setfTypeid(fId);
  419. }
  420. break;
  421. case "最新地点":
  422. //设置单元格类型
  423. cell.setCellType(CellType.STRING);
  424. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  425. /*return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少最新地点");*/
  426. break;
  427. }
  428. companyMsg.setAddressName((cell.getStringCellValue()));
  429. break;
  430. case "租赁公司":
  431. //设置单元格类型
  432. cell.setCellType(CellType.STRING);
  433. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  434. /*return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少货名");*/
  435. break;
  436. }
  437. companyMsg.setOwnerName(cell.getStringCellValue());
  438. if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
  439. String fPackageid = sysDictDataMapper.selectDictValue("f_owner", cell.getStringCellValue());
  440. if (StringUtils.isNotEmpty(fPackageid)) {
  441. companyMsg.setfOwner(fPackageid);
  442. }
  443. }
  444. break;
  445. case "箱状态":
  446. //设置单元格类型
  447. cell.setCellType(CellType.STRING);
  448. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  449. /*return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱状态");*/
  450. break;
  451. }
  452. companyMsg.setCntrstatusName(cell.getStringCellValue());
  453. if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
  454. String setCntrstatusid = sysDictDataMapper.selectDictValue("f_cntrstatus", cell.getStringCellValue());
  455. if (StringUtils.isNotEmpty(setCntrstatusid)) {
  456. companyMsg.setfCntrstatus(setCntrstatusid);
  457. }
  458. }
  459. break;
  460. case "空重":
  461. //设置单元格类型
  462. cell.setCellType(CellType.STRING);
  463. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  464. /*return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱型");*/
  465. break;
  466. }
  467. companyMsg.setUpdateEFName(cell.getStringCellValue());
  468. if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
  469. String setUpdateEFid = sysDictDataMapper.selectDictValue("f_updateEF", cell.getStringCellValue());
  470. if (StringUtils.isNotEmpty(setUpdateEFid)) {
  471. companyMsg.setfUpdateef(setUpdateEFid);
  472. }
  473. }
  474. break;
  475. case "地点类型":
  476. //设置单元格类型
  477. cell.setCellType(CellType.STRING);
  478. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  479. /*return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少地点类型");*/
  480. break;
  481. }
  482. companyMsg.setAddressType(cell.getStringCellValue());
  483. if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
  484. String fPackageid = sysDictDataMapper.selectDictValue("f_types", cell.getStringCellValue());
  485. if (StringUtils.isNotEmpty(fPackageid)) {
  486. companyMsg.setAddressTypeId(fPackageid);
  487. }
  488. }
  489. break;
  490. case "合同协议号":
  491. cell.setCellType(CellType.STRING);
  492. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  493. /*return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少合同协议号");*/
  494. break;
  495. }
  496. companyMsg.setfPactDealHorn(cell.getStringCellValue());
  497. break;
  498. case "起租时间":
  499. cell.setCellType(CellType.NUMERIC);
  500. if (ObjectUtils.isEmpty(cell.getDateCellValue())) {
  501. /*return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少起租时间");*/
  502. break;
  503. }
  504. companyMsg.setOnHireStart(cell.getDateCellValue());
  505. break;
  506. /*case "箱来源":
  507. //设置单元格类型
  508. cell.setCellType(CellType.STRING);
  509. companyMsg.setSourceName(cell.getStringCellValue());
  510. if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
  511. String setSourceid = sysDictDataMapper.selectDictValue("f_source", cell.getStringCellValue());
  512. if (StringUtils.isNotEmpty(setSourceid)) {
  513. companyMsg.setfSource(setSourceid);
  514. }
  515. }
  516. break;
  517. case "租赁方式":
  518. //设置单元格类型
  519. cell.setCellType(CellType.STRING);
  520. companyMsg.setRentName(cell.getStringCellValue());
  521. if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
  522. String setRentid = sysDictDataMapper.selectDictValue("f_rent", cell.getStringCellValue());
  523. if (StringUtils.isNotEmpty(setRentid)) {
  524. companyMsg.setfRent(setRentid);
  525. }
  526. }
  527. break;
  528. case "备注":
  529. //设置单元格类型
  530. cell.setCellType(CellType.STRING);
  531. companyMsg.setRemark(cell.getStringCellValue());
  532. break;*/
  533. }
  534. if (StringUtils.isNotEmpty(companyMsg.getAddressName()) && StringUtils.isNotEmpty(companyMsg.getAddressTypeId())) {
  535. TAddress tAddress = new TAddress();
  536. tAddress.setfName(companyMsg.getAddressName());
  537. tAddress.setfTypes(companyMsg.getAddressTypeId());
  538. TAddress address = tAddressMapper.selectAddressFName(tAddress);
  539. if (address != null){
  540. companyMsg.setfUpdateaddress(address.getfId().toString());
  541. }
  542. }
  543. }
  544. if (StringUtils.isNotEmpty(companyMsg.getfNo())){
  545. fleetCompanyMsgs.add(companyMsg);
  546. }
  547. }
  548. fleetCompanyMsgs = fleetCompanyMsgs.stream().filter(distinctByKey(TCntrnoExcel::getfNo)).collect(Collectors.toList());
  549. } catch (IOException e) {
  550. return AjaxResult.error("上传文件失败,请检查文件是否损坏");
  551. }
  552. return AjaxResult.success("success", fleetCompanyMsgs);
  553. }
  554. @Override
  555. @Transactional
  556. public AjaxResult batch(String tCntrno, LoginUser loginUser) {
  557. JSONArray jsonCrArray = JSONArray.parseArray(tCntrno);
  558. List<TCntrno> tCntrnoList = JSONObject.parseArray(jsonCrArray.toJSONString(), TCntrno.class);
  559. StringBuffer stringBuffer = new StringBuffer();
  560. if (CollectionUtils.isNotEmpty(tCntrnoList)) {
  561. for (TCntrno cntrno : tCntrnoList) {
  562. if (UserConstants.NOT_UNIQUE.equals(this.selectTCntrnoFNo(cntrno))) {
  563. stringBuffer.append(cntrno.getfNo() + "编号已存在,");
  564. continue;
  565. } else {
  566. cntrno.setCreateTime(DateUtils.getNowDate());
  567. cntrno.setCreateBy(SecurityUtils.getUsername());
  568. cntrno.setfUpdatetime(DateUtils.getNowDate());
  569. cntrno.setfStatus("T");
  570. tCntrnoMapper.insertTCntrno(cntrno);
  571. }
  572. }
  573. }
  574. if (StringUtils.isNotEmpty(stringBuffer)){
  575. return AjaxResult.success("success",stringBuffer.toString());
  576. }else {
  577. return AjaxResult.success();
  578. }
  579. }
  580. @Override
  581. public List<Map<String, Object>> getTcntrnoFno(TCntrno tCntrno) {
  582. return tCntrnoMapper.getTcntrnoFno(tCntrno);
  583. }
  584. @Override
  585. public AjaxResult importAirForceStation(MultipartFile file) throws Exception{
  586. List<TCntrno> tCntrno = new ArrayList<>();
  587. InputStream inputStream = null;
  588. inputStream = file.getInputStream();
  589. ZipSecureFile.setMinInflateRatio(-1.0d);
  590. String originalFilename = file.getOriginalFilename();
  591. Workbook workbook = null;
  592. if (originalFilename.endsWith("xls")){
  593. workbook = WorkbookFactory.create(inputStream);
  594. }else if (originalFilename.endsWith("xlsx")){
  595. workbook = new XSSFWorkbook(inputStream);
  596. }
  597. Sheet sheet = workbook.getSheetAt(0);
  598. int line = 0;
  599. for (Row rows : sheet) {
  600. line++;
  601. if (rows.getRowNum() == 0) {
  602. continue;
  603. }
  604. TCntrno companyMsg = new TCntrno();
  605. for (int a = 0; a < rows.getPhysicalNumberOfCells(); a++) {
  606. Cell cell = rows.getCell(a);
  607. if (cell == null){
  608. continue;
  609. }
  610. String value = filter(sheet.getRow(0), CellReference.convertNumToColString(cell.getColumnIndex()));
  611. switch (value) {
  612. case "箱动态":
  613. //设置单元格类型
  614. cell.setCellType(CellType.STRING);
  615. companyMsg.setOpctnstatusName(cell.getStringCellValue());
  616. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  617. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱动态");
  618. }
  619. String fOpCTnsTaTus = sysDictDataMapper.selectDictValue("f_opctnstatus", cell.getStringCellValue());
  620. if (StringUtils.isEmpty(fOpCTnsTaTus)){
  621. return AjaxResult.error("系统缺少箱动态"+cell.getStringCellValue()+"请维护");
  622. }
  623. companyMsg.setfOpctnstatus(fOpCTnsTaTus);
  624. break;
  625. case "箱号":
  626. //设置单元格类型
  627. cell.setCellType(CellType.STRING);
  628. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  629. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱号");
  630. }
  631. companyMsg.setfNo(cell.getStringCellValue());
  632. break;
  633. case "空重":
  634. //设置单元格类型
  635. cell.setCellType(CellType.STRING);
  636. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  637. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少空重");
  638. }
  639. String fUpDaTeEf = sysDictDataMapper.selectDictValue("f_updateEF", cell.getStringCellValue());
  640. if (StringUtils.isEmpty(fUpDaTeEf)){
  641. return AjaxResult.error("系统缺少空重:"+cell.getStringCellValue()+"请维护");
  642. }
  643. companyMsg.setfUpdateef(fUpDaTeEf);
  644. companyMsg.setUpdateEFName(cell.getStringCellValue());
  645. break;
  646. case "动态日期":
  647. //设置单元格类型
  648. cell.setCellType(CellType.STRING);
  649. String dataFormatString = cell.getStringCellValue();
  650. if (StringUtils.isEmpty(dataFormatString)) {
  651. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少动态日期");
  652. }
  653. Date parse = null;
  654. try {
  655. parse = HSSFDateUtil.getJavaDate(Double.valueOf(dataFormatString));
  656. }catch (Exception e){
  657. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  658. parse = simpleDateFormat.parse(dataFormatString);
  659. }
  660. companyMsg.setfUpdatetime(parse);
  661. break;
  662. case "船名":
  663. //设置单元格类型
  664. cell.setCellType(CellType.STRING);
  665. /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
  666. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少船名");
  667. }*/
  668. companyMsg.setfVsl(cell.getStringCellValue());
  669. break;
  670. case "航次":
  671. //设置单元格类型
  672. cell.setCellType(CellType.STRING);
  673. /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
  674. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少航次");
  675. }*/
  676. companyMsg.setfVoy(cell.getStringCellValue());
  677. break;
  678. case "重量":
  679. //设置单元格类型
  680. cell.setCellType(CellType.STRING);
  681. /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
  682. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少重量");
  683. }*/
  684. BigDecimal bigDecimal = new BigDecimal(cell.getStringCellValue());
  685. companyMsg.setfBoxWeight(bigDecimal);
  686. break;
  687. case "地点类型 如: 堆场,码头":
  688. //设置单元格类型
  689. cell.setCellType(CellType.STRING);
  690. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  691. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少港口名称");
  692. }
  693. String fTypes = sysDictDataMapper.selectDictValue("f_types", cell.getStringCellValue());
  694. if (StringUtils.isEmpty(fTypes)){
  695. return AjaxResult.error("系统缺少地点类型"+cell.getStringCellValue()+"请维护");
  696. }
  697. companyMsg.setPort(fTypes);
  698. companyMsg.setPortName(cell.getStringCellValue());
  699. break;
  700. case "堆放地点":
  701. //设置单元格类型
  702. cell.setCellType(CellType.STRING);
  703. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  704. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少堆放地点");
  705. }
  706. companyMsg.setAddressName(cell.getStringCellValue());
  707. if (StringUtils.isEmpty(companyMsg.getPort())){
  708. return AjaxResult.error("缺少地点类型"+companyMsg.getPortName());
  709. }
  710. TAddress aLong = tAddressMapper.selectTAddressByfNameType(cell.getStringCellValue(), companyMsg.getPort());
  711. if (aLong == null){
  712. return AjaxResult.error("系统缺少类型为"+companyMsg.getPortName()+"的地点"+cell.getStringCellValue()+"请维护");
  713. }
  714. companyMsg.setfUpdateaddress(aLong.getfId().toString());
  715. break;
  716. case "提单号":
  717. //设置单元格类型
  718. cell.setCellType(CellType.STRING);
  719. /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
  720. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少提单号");
  721. }*/
  722. companyMsg.setfMblno(cell.getStringCellValue());
  723. break;
  724. case "铅封号":
  725. //设置单元格类型
  726. cell.setCellType(CellType.STRING);
  727. /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
  728. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少铅封号");
  729. }*/
  730. companyMsg.setfSealno(cell.getStringCellValue());
  731. break;
  732. case "是否箱损 如:好,坏":
  733. //设置单元格类型
  734. cell.setCellType(CellType.STRING);
  735. companyMsg.setCntrstatusName(cell.getStringCellValue());
  736. if (StringUtils.isEmpty(cell.getStringCellValue())) {
  737. return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱损状态");
  738. }
  739. String fCnTrsTaTus = sysDictDataMapper.selectDictValue("f_cntrstatus", cell.getStringCellValue());
  740. if (StringUtils.isEmpty(fCnTrsTaTus)){
  741. return AjaxResult.error("系统缺少箱状态"+cell.getStringCellValue()+"请维护");
  742. }
  743. companyMsg.setfCntrstatus(fCnTrsTaTus);
  744. break;
  745. case "箱损描述(备注)":
  746. //设置单元格类型
  747. cell.setCellType(CellType.STRING);
  748. companyMsg.setRemark(cell.getStringCellValue());
  749. break;
  750. }
  751. }
  752. tCntrno.add(companyMsg);
  753. }
  754. return AjaxResult.success("success", tCntrno);
  755. }
  756. @Override
  757. public List<BoxDistributionStatistics> boxDistributedStatistics() {
  758. List<BoxDistributionStatistics> list = new ArrayList<>();
  759. //先获取箱地址为港口信息
  760. List<TCntrno> boxPortMessage = tCntrnoMapper.getBoxPortMessage();
  761. //获取箱信息地址不为港口的信息
  762. List<TCntrno> addressMessageList = tCntrnoMapper.getBoxAddressMessage();
  763. //获取箱动态信息
  764. List<SysDictData> fOpcTnsTaTus = sysDictDataMapper.selectDictDataByType("f_opctnstatus");
  765. //获取箱空重状态
  766. List<SysDictData> fUpdateEF = sysDictDataMapper.selectDictDataByType("f_updateEF");
  767. //获取箱好坏状态
  768. List<SysDictData> fCnTrStatus = sysDictDataMapper.selectDictDataByType("f_cntrstatus");
  769. //在获取港口下的堆场对应的箱信息
  770. if (CollectionUtils.isNotEmpty(boxPortMessage) && CollectionUtils.isNotEmpty(fOpcTnsTaTus)){
  771. for (TCntrno cntrno : boxPortMessage) {
  772. BoxDistributionStatistics boxDistributionStatistics = new BoxDistributionStatistics();
  773. boxDistributionStatistics.setHaven(cntrno.getAddressName());
  774. List<BoxAddressMessage> boxAddressMessageList = new ArrayList<>();
  775. if (CollectionUtils.isNotEmpty(addressMessageList)){
  776. for (TCntrno trno : addressMessageList) {
  777. if (cntrno.getAddressName().equals(trno.getPortName()) && !trno.getAddressName().equals("在船")){
  778. List<BoxMessage> boxMessageList = new ArrayList<>();
  779. BoxAddressMessage boxAddressMessage = new BoxAddressMessage();
  780. boxAddressMessage.setAddress(trno.getAddressName());
  781. boxAddressMessage.setNumberSize(fOpcTnsTaTus.size()+fUpdateEF.size()+fCnTrStatus.size());
  782. List<BoxMessage> opcTnsTaTus = this.getOpcTnsTaTus(fOpcTnsTaTus, trno);//获取调箱状态的箱新
  783. List<BoxMessage> updateEF = this.getUpdateEF(fUpdateEF, trno);//获取空重的箱信息
  784. List<BoxMessage> cnTrStatus = this.getCnTrStatus(fCnTrStatus, trno);//获取好坏的箱信息
  785. if (CollectionUtils.isNotEmpty(opcTnsTaTus)){
  786. boxMessageList.addAll(opcTnsTaTus);
  787. }
  788. if (CollectionUtils.isNotEmpty(updateEF)){
  789. boxMessageList.addAll(updateEF);
  790. }if (CollectionUtils.isNotEmpty(cnTrStatus)){
  791. boxMessageList.addAll(cnTrStatus);
  792. }
  793. boxAddressMessage.setBoxMessages(boxMessageList);
  794. boxAddressMessageList.add(boxAddressMessage);
  795. }else if (cntrno.getAddressName().equals(trno.getPortName()) && trno.getAddressName().equals("在船")){
  796. //获取在船的备注
  797. List<TCntrno> boxRemark = tCntrnoMapper.getBoxRemark(trno.getfUpdateaddress());
  798. if (CollectionUtils.isNotEmpty(boxRemark)){
  799. for (TCntrno tCntrno : boxRemark) {
  800. List<BoxMessage> boxMessageList = new ArrayList<>();
  801. BoxAddressMessage boxAddressMessage = new BoxAddressMessage();
  802. boxAddressMessage.setAddress(trno.getAddressName()+tCntrno.getRemark());
  803. boxAddressMessage.setNumberSize(fOpcTnsTaTus.size()+fUpdateEF.size()+fCnTrStatus.size());
  804. List<BoxMessage> opcTnsTaTus = this.getOpcTnsTaTus(fOpcTnsTaTus, trno);//获取调箱状态的箱新
  805. List<BoxMessage> updateEF = this.getUpdateEF(fUpdateEF, trno);//获取空重的箱信息
  806. List<BoxMessage> cnTrStatus = this.getCnTrStatus(fCnTrStatus, trno);//获取好坏的箱信息
  807. if (CollectionUtils.isNotEmpty(opcTnsTaTus)){
  808. boxMessageList.addAll(opcTnsTaTus);
  809. }
  810. if (CollectionUtils.isNotEmpty(updateEF)){
  811. boxMessageList.addAll(updateEF);
  812. }if (CollectionUtils.isNotEmpty(cnTrStatus)){
  813. boxMessageList.addAll(cnTrStatus);
  814. }
  815. boxAddressMessage.setBoxMessages(boxMessageList);
  816. boxAddressMessageList.add(boxAddressMessage);
  817. }
  818. }
  819. }
  820. }
  821. }
  822. boxDistributionStatistics.setBoxAddressMessages(boxAddressMessageList);
  823. boxDistributionStatistics.setNumber(fOpcTnsTaTus.size()*boxAddressMessageList.size()+fUpdateEF.size()*boxAddressMessageList.size()+fCnTrStatus.size()*boxAddressMessageList.size());
  824. list.add(boxDistributionStatistics);
  825. }
  826. }
  827. return list;
  828. }
  829. @Override
  830. public List<Map<String, Object>> homeBox() {
  831. List<Map<String, Object>> list = tCntrnoMapper.homeBox();
  832. list.get(list.size() - 1).put("details", tCntrnoMapper.homeBoxCount());
  833. return list;
  834. }
  835. @Override
  836. @Transactional
  837. public int updateHire(TCntrno tCntrno) {
  838. return tCntrnoMapper.updateHire(tCntrno);
  839. }
  840. /**
  841. * set字段
  842. *
  843. * @param tCntrno
  844. * @return
  845. */
  846. public TCntrtracking setfield(TCntrno tCntrno) {
  847. TCntrtracking tCntrtracking = new TCntrtracking();
  848. BeanUtils.copyProperties(tCntrno, tCntrtracking);
  849. tCntrtracking.setfId(null);
  850. return tCntrtracking;
  851. }
  852. public List<String> GetMapKey(List<Map<String, Object>> listResult) {
  853. if ((listResult != null) && (!listResult.isEmpty())) {
  854. List listKey = new ArrayList();
  855. Map mapResult = (Map) listResult.get(0);
  856. Set mapKeySet = mapResult.keySet();
  857. String listHead = "";
  858. Iterator iteratorKey = mapKeySet.iterator();
  859. while (iteratorKey.hasNext()) {
  860. listHead = iteratorKey.next().toString();
  861. listKey.add(listHead);
  862. }
  863. return listKey;
  864. }
  865. return null;
  866. }
  867. private static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
  868. Map<Object, Boolean> seen = new ConcurrentHashMap<>();
  869. return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
  870. }
  871. /**
  872. * 获取调箱动态的箱信息
  873. * @param fOpcTnsTaTus
  874. * @param trno
  875. * @return
  876. */
  877. public List<BoxMessage> getOpcTnsTaTus(List<SysDictData> fOpcTnsTaTus,TCntrno trno){
  878. List<BoxMessage> boxMessageList = new ArrayList<>();
  879. if (CollectionUtils.isNotEmpty(fOpcTnsTaTus)){
  880. for (SysDictData opcTnsTaTus : fOpcTnsTaTus) {
  881. TCntrno tro = new TCntrno();
  882. BoxMessage boxMessage = new BoxMessage();
  883. tro.setfUpdateaddress(trno.getfUpdateaddress());
  884. tro.setfOpctnstatus(opcTnsTaTus.getDictValue());
  885. BoxMessage message = tCntrnoMapper.boxDistributionStatistics(tro);
  886. if (message != null){
  887. boxMessage = message;
  888. }
  889. boxMessage.setOpcTnStatus(opcTnsTaTus.getDictLabel());
  890. boxMessage.setUNIT(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
  891. +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()+boxMessage.getFORTYGP()
  892. +boxMessage.getFORTYHC()+boxMessage.getFORTYHR()+boxMessage.getFORTYOT()+boxMessage.getFORTYTK());
  893. boxMessage.setTEU(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
  894. +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()*2+boxMessage.getFORTYGP()*2
  895. +boxMessage.getFORTYHC()*2+boxMessage.getFORTYHR()*2+boxMessage.getFORTYOT()*2+boxMessage.getFORTYTK()*2);
  896. boxMessageList.add(boxMessage);
  897. }
  898. }
  899. return boxMessageList;
  900. }
  901. public List<BoxMessage> getUpdateEF(List<SysDictData> fUpdateEF,TCntrno trno){
  902. List<BoxMessage> boxMessageList = new ArrayList<>();
  903. if (CollectionUtils.isNotEmpty(fUpdateEF)){
  904. for (SysDictData sysDictData : fUpdateEF) {
  905. TCntrno tro = new TCntrno();
  906. BoxMessage boxMessage = new BoxMessage();
  907. tro.setfUpdateaddress(trno.getfUpdateaddress());
  908. tro.setfUpdateef(sysDictData.getDictValue());
  909. BoxMessage message = tCntrnoMapper.boxDistributionStatistics(tro);
  910. if (message != null){
  911. boxMessage = message;
  912. }
  913. boxMessage.setOpcTnStatus(sysDictData.getDictLabel());
  914. boxMessage.setUNIT(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
  915. +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()+boxMessage.getFORTYGP()
  916. +boxMessage.getFORTYHC()+boxMessage.getFORTYHR()+boxMessage.getFORTYOT()+boxMessage.getFORTYTK());
  917. boxMessage.setTEU(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
  918. +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()*2+boxMessage.getFORTYGP()*2
  919. +boxMessage.getFORTYHC()*2+boxMessage.getFORTYHR()*2+boxMessage.getFORTYOT()*2+boxMessage.getFORTYTK()*2);
  920. boxMessageList.add(boxMessage);
  921. }
  922. }
  923. return boxMessageList;
  924. }
  925. public List<BoxMessage> getCnTrStatus(List<SysDictData> fCnTrStatus,TCntrno trno){
  926. List<BoxMessage> boxMessageList = new ArrayList<>();
  927. if (CollectionUtils.isNotEmpty(fCnTrStatus)){
  928. for (SysDictData cnTrStatus : fCnTrStatus) {
  929. TCntrno tro = new TCntrno();
  930. BoxMessage boxMessage = new BoxMessage();
  931. tro.setfUpdateaddress(trno.getfUpdateaddress());
  932. tro.setfCntrstatus(cnTrStatus.getDictValue());
  933. BoxMessage message = tCntrnoMapper.boxDistributionStatistics(tro);
  934. if (message != null){
  935. boxMessage = message;
  936. }
  937. boxMessage.setOpcTnStatus(cnTrStatus.getDictLabel());
  938. boxMessage.setUNIT(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
  939. +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()+boxMessage.getFORTYGP()
  940. +boxMessage.getFORTYHC()+boxMessage.getFORTYHR()+boxMessage.getFORTYOT()+boxMessage.getFORTYTK());
  941. boxMessage.setTEU(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
  942. +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()*2+boxMessage.getFORTYGP()*2
  943. +boxMessage.getFORTYHC()*2+boxMessage.getFORTYHR()*2+boxMessage.getFORTYOT()*2+boxMessage.getFORTYTK()*2);
  944. boxMessageList.add(boxMessage);
  945. }
  946. }
  947. return boxMessageList;
  948. }
  949. }