AdminDetectController.java 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515
  1. package com.iamberry.rst.controllers.cm;
  2. import com.iamberry.rst.core.cm.CompanyInfo;
  3. import com.iamberry.rst.core.cm.ComplaintQuestionInfo;
  4. import com.iamberry.rst.core.cm.ProcType;
  5. import com.iamberry.rst.core.cm.SalesOrder;
  6. import com.iamberry.rst.core.fm.*;
  7. import com.iamberry.rst.core.order.Product;
  8. import com.iamberry.rst.core.order.ProductColor;
  9. import com.iamberry.rst.core.order.ProductType;
  10. import com.iamberry.rst.core.page.PageRequest;
  11. import com.iamberry.rst.core.page.PagedResult;
  12. import com.iamberry.rst.core.sys.Admin;
  13. import com.iamberry.rst.core.tools.LogisticsInfo;
  14. import com.iamberry.rst.faces.cm.CompanyInfoService;
  15. import com.iamberry.rst.faces.cm.ProcTypeService;
  16. import com.iamberry.rst.faces.cm.SalesOrderService;
  17. import com.iamberry.rst.faces.fm.*;
  18. import com.iamberry.rst.faces.product.ProductService;
  19. import com.iamberry.rst.service.cm.mapper.ComplaintQuestionInfoMapper;
  20. import com.iamberry.rst.service.sys.mapper.SysMapper;
  21. import com.iamberry.rst.utils.AdminUtils;
  22. import com.iamberry.rst.utils.GenerateKeyUtil;
  23. import com.iamberry.rst.utils.StitchAttrUtil;
  24. import com.iamberry.wechat.tools.ResponseJson;
  25. import org.apache.poi.hssf.usermodel.*;
  26. import org.apache.shiro.authz.annotation.RequiresPermissions;
  27. import org.springframework.beans.factory.annotation.Autowired;
  28. import org.springframework.stereotype.Controller;
  29. import org.springframework.web.bind.annotation.RequestMapping;
  30. import org.springframework.web.bind.annotation.RequestParam;
  31. import org.springframework.web.bind.annotation.ResponseBody;
  32. import org.springframework.web.servlet.ModelAndView;
  33. import javax.servlet.ServletOutputStream;
  34. import javax.servlet.http.HttpServletRequest;
  35. import javax.servlet.http.HttpServletResponse;
  36. import java.io.*;
  37. import java.text.ParseException;
  38. import java.text.SimpleDateFormat;
  39. import java.util.*;
  40. /**
  41. * Created by wxm on 2017/8/29.
  42. */
  43. @Controller
  44. @RequestMapping("/admin/detect")
  45. public class AdminDetectController {
  46. // private
  47. @Autowired
  48. private ComplaintDetectInfoService complaintDetectInfoService;
  49. @Autowired
  50. private ProductService productService;
  51. @Autowired
  52. private ComplaintSignclosedInfoService complaintSignclosedInfoService;
  53. @Autowired
  54. private ComplaintSignclosedProductInfoService signclosedProductInfoService;
  55. @Autowired
  56. private AwaitingSignclosedProductInfoService awaitingSignclosedProductService;
  57. @Autowired
  58. private CompanyInfoService companyInfoService;
  59. @Autowired
  60. private SalesOrderService salesOrderService;
  61. @Autowired
  62. private GenerateKeyUtil generateKeyUtil;
  63. @Autowired
  64. private ComplaintQuestionInfoMapper complaintQuestionInfoMapper;
  65. @Autowired
  66. private SysMapper sysMapper;
  67. @Autowired
  68. private ProcTypeService procTypeService;
  69. @Autowired
  70. private DetectStatisticService detectStatisticService;
  71. /**
  72. * 跳转到添加检测记录页面
  73. *
  74. * @return
  75. */
  76. @RequiresPermissions("detect:add:detect")
  77. @RequestMapping(value = "/to_add_detect")
  78. public ModelAndView toAddDetect(HttpServletRequest request) {
  79. ModelAndView mv = new ModelAndView("cm/inspection/add_detect");
  80. Product product = new Product();
  81. List<Product> productList = productService.listProductAndColorAndfittings(product);
  82. ProductColor color = new ProductColor();
  83. color.setColorProductId(product.getProductId());
  84. List<ProductColor> productColorList = productService.listProduceColor(color);
  85. mv.addObject("productColorList",productColorList);
  86. mv.addObject("productList",productList);
  87. //获取所有维修内容
  88. DetectionBasis detectionBasis = new DetectionBasis();
  89. List<DetectionBasis> detectionBasisList = complaintDetectInfoService.listDetectionBasis(detectionBasis);
  90. //查询客诉问题
  91. ComplaintQuestionInfo complaintQuestionInfo = new ComplaintQuestionInfo();
  92. complaintQuestionInfo.setDetectComplaintType(1);
  93. List<ComplaintQuestionInfo> listComplaintQuestionInfo = complaintQuestionInfoMapper.listComplaintQuestionInfo(complaintQuestionInfo);
  94. //查询业务员
  95. Admin admin = new Admin();
  96. admin.setAdminDept(15);
  97. List<Admin> listAdmin = sysMapper.listAdmin(admin);
  98. mv.addObject("listAdmin",listAdmin);
  99. mv.addObject("listComplaintQuestionInfo",listComplaintQuestionInfo);
  100. mv.addObject("detectionBasisList",detectionBasisList);
  101. List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
  102. mv.addObject("companyInfoList",companyInfoList);
  103. return mv;
  104. }
  105. /**
  106. * 客诉 - 查询品质检测列表
  107. * @param request
  108. * @return
  109. */
  110. @RequiresPermissions("detect:select:detect")
  111. @RequestMapping("/select_detect_list")
  112. public ModelAndView selectDetectList(HttpServletRequest request,
  113. @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
  114. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  115. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum,
  116. ComplaintDetectInfo detect) throws ParseException {
  117. ModelAndView mv = new ModelAndView("cm/inspection/detect_list");
  118. detect.setDetectSource(1);
  119. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  120. // 封装请求数据
  121. PageRequest<ComplaintDetectInfo> pageRequest = new PageRequest<>(detect, pageNO, pageSize, totalNum == 0);
  122. // 查询订单列表
  123. PagedResult<ComplaintDetectInfo> result = complaintDetectInfoService.listComplaintDetect(pageRequest);
  124. if (totalNum != 0) {
  125. result.setTotal(totalNum);
  126. }
  127. //获取所有产品类型
  128. ProductType productType = new ProductType();
  129. List<ProductType> productTypeList = productService.listProductType(productType);
  130. mv.addObject("productTypeList",productTypeList);
  131. Product product = new Product();
  132. List<Product> productList = productService.listProductAndColorAndfittings(product);
  133. mv.addObject("productList",productList);
  134. //查询各个状态数量
  135. ComplaintAfterSalesNum complaintAfterSalesNum = complaintDetectInfoService.getDetectCount();
  136. mv.addObject("complaintAfterSalesNum",complaintAfterSalesNum);
  137. StitchAttrUtil.getSa().setModelAndView(detect, mv, "/admin/detect/select_detect_list", result);
  138. return mv;
  139. }
  140. /**
  141. * 添加检测信息
  142. * @param request
  143. * @return
  144. * @throws Exception
  145. */
  146. @RequiresPermissions("detect:add:detect")
  147. @ResponseBody
  148. @RequestMapping("/add_detect")
  149. public ResponseJson addDetect(HttpServletRequest request, ComplaintDetectInfo detectInfo) throws Exception {
  150. ResponseJson msg = new ResponseJson();
  151. if(detectInfo == null){
  152. msg.setResultCode(500);
  153. msg.setReturnCode(500);
  154. return msg;
  155. }
  156. /*String itemDate = request.getParameter("itemDate");
  157. if(itemDate == null ){
  158. msg.setResultCode(500);
  159. msg.setReturnCode(500);
  160. return msg;
  161. }*/
  162. //生成维修编号
  163. String number = generateKeyUtil.detectNumber();
  164. detectInfo.setDetectNumber(number);
  165. detectInfo.setDetectState(1);
  166. detectInfo.setIsMaintenance(0);
  167. detectInfo.setDetectRenovation(0);
  168. detectInfo.setDetectProcessingResults(0);
  169. Calendar date = Calendar.getInstance();
  170. date.setTime(new Date());
  171. boolean fl = false;
  172. for (int i = 1 ; i <= 3; i++){
  173. date.set(Calendar.DATE, date.get(Calendar.DATE) + i);
  174. int week = date.get(Calendar.DAY_OF_WEEK);//1--7的值,对应:星期日,星期一,星期二,星期三....星期六
  175. if(week == 1){
  176. fl = true;
  177. }
  178. date.set(Calendar.DATE, date.get(Calendar.DATE) - i);
  179. }
  180. if(fl){
  181. date.set(Calendar.DATE, date.get(Calendar.DATE) + 4);
  182. }else{
  183. date.set(Calendar.DATE, date.get(Calendar.DATE) + 3);
  184. }
  185. detectInfo.setMaintenanceCutTime(date.getTime());
  186. detectInfo.setDetectSource(2);
  187. if(complaintDetectInfoService.insert(detectInfo) > 0){
  188. msg.setResultCode(200);
  189. msg.setReturnCode(200);
  190. }else{
  191. msg.setResultCode(500);
  192. msg.setReturnCode(500);
  193. }
  194. return msg;
  195. }
  196. /**
  197. * 跳转到添加维修记录页面
  198. *
  199. * @return
  200. */
  201. @RequiresPermissions("info:update:info")
  202. @RequestMapping(value = "/to_add_content")
  203. public ModelAndView toAddContent(HttpServletRequest request) {
  204. ModelAndView mv = new ModelAndView("cm/inspection/add_content");
  205. String detectId = request.getParameter("detectId");
  206. if(detectId == null || detectId.equals("")){
  207. return mv;
  208. }
  209. ComplaintDetectInfo detectinfo = complaintDetectInfoService.getDetectById(Integer.valueOf(detectId));
  210. mv.addObject("detectId",detectId);
  211. mv.addObject("detectinfo",detectinfo);
  212. return mv;
  213. }
  214. /**
  215. * 跳转到修改QC检测结果页面
  216. *
  217. * @return
  218. */
  219. @RequiresPermissions("info:update:info")
  220. @RequestMapping(value = "/to_add_QC")
  221. public ModelAndView toAddQC(HttpServletRequest request) {
  222. ModelAndView mv = new ModelAndView("cm/inspection/add_QC");
  223. String detectId = request.getParameter("detectId");
  224. if(detectId == null || detectId.equals("")){
  225. return mv;
  226. }
  227. ComplaintDetectInfo detectinfo = complaintDetectInfoService.getDetectById(Integer.valueOf(detectId));
  228. mv.addObject("detectId",detectId);
  229. mv.addObject("detectinfo",detectinfo);
  230. return mv;
  231. }
  232. /**
  233. * 跳转到完成维修页面
  234. *
  235. * @return
  236. */
  237. @RequiresPermissions("info:update:info")
  238. @RequestMapping(value = "/to_complete")
  239. public ModelAndView toComplete(HttpServletRequest request) {
  240. ModelAndView mv = new ModelAndView("cm/inspection/complete_maintenance");
  241. String detectId = request.getParameter("detectId");
  242. String detectState = request.getParameter("detectState");
  243. if(detectId == null || detectId.equals("")){
  244. return mv;
  245. }if(detectState == null || detectState.equals("")){
  246. return mv;
  247. }
  248. ComplaintDetectInfo detectinfo = complaintDetectInfoService.getDetectById(Integer.valueOf(detectId));
  249. List<DetectionConfig> config2 = complaintDetectInfoService.listDetectionConfig(2);
  250. List<DetectionConfig> config3 = complaintDetectInfoService.listDetectionConfig(3);
  251. List<DetectionConfig> config4 = complaintDetectInfoService.listDetectionConfig(4);
  252. List<DetectionConfig> config5 = complaintDetectInfoService.listDetectionConfig(5);
  253. mv.addObject("config2",config2);
  254. mv.addObject("config3",config3);
  255. mv.addObject("config4",config4);
  256. mv.addObject("config5",config5);
  257. List<MaterialNumberInfo> listMaterial = complaintDetectInfoService.listMaterialNumber();
  258. mv.addObject("detectId",detectId);
  259. mv.addObject("detectState",detectState);
  260. mv.addObject("detectinfo",detectinfo);
  261. mv.addObject("listMaterial",listMaterial);
  262. return mv;
  263. }
  264. /**
  265. * 跳转到检测详情页面
  266. *
  267. * @return
  268. */
  269. @RequiresPermissions("info:update:info")
  270. @RequestMapping(value = "/to_detail")
  271. public ModelAndView toAddDetail(HttpServletRequest request) {
  272. ModelAndView mv = new ModelAndView("cm/inspection/detect_detail");
  273. String detectId = request.getParameter("detectId");
  274. if(detectId == null || detectId.equals("")){
  275. return mv;
  276. }
  277. ComplaintDetectInfo detectinfo = complaintDetectInfoService.getDetectById(Integer.valueOf(detectId));
  278. List<ComplaintDetectImg> imgList = complaintDetectInfoService.listDetectImg(Integer.valueOf(detectId));
  279. List<MaterialItem> listMaterialItem = complaintDetectInfoService.listMaterialItem(Integer.valueOf(detectId));
  280. List<QcInfo> listQcInfo = complaintDetectInfoService.listQcInfo(Integer.valueOf(detectId));
  281. List<TreatmentRecordLog> listTreatmentRecordLog = complaintDetectInfoService.listTreatmentRecordLog(Integer.valueOf(detectId));
  282. if(detectinfo.getSalesOrderId() != null){
  283. SalesOrder salesOrder = salesOrderService.getSalesOrderByOrderId(detectinfo.getSalesOrderId());
  284. mv.addObject("salesOrder",salesOrder);
  285. }
  286. DetectionItem detectionItem = new DetectionItem();
  287. detectionItem.setDetectId(Integer.valueOf(detectId));
  288. //查询检测现象
  289. detectionItem.setConfigType(1);
  290. mv.addObject("detectPhenomenonList",complaintDetectInfoService.listDetectionItem(detectionItem));
  291. //查询故障原因
  292. detectionItem.setConfigType(2);
  293. mv.addObject("detectFailureCauseList",complaintDetectInfoService.listDetectionItem(detectionItem));
  294. //查询判定结果
  295. detectionItem.setConfigType(3);
  296. mv.addObject("detectResultsList",complaintDetectInfoService.listDetectionItem(detectionItem));
  297. //查询故障指向
  298. detectionItem.setConfigType(4);
  299. mv.addObject("detectPointList",complaintDetectInfoService.listDetectionItem(detectionItem));
  300. //查询原因分析
  301. detectionItem.setConfigType(5);
  302. mv.addObject("detectNalysisList",complaintDetectInfoService.listDetectionItem(detectionItem));
  303. mv.addObject("listTreatmentRecordLog",listTreatmentRecordLog);
  304. mv.addObject("listQcInfo",listQcInfo);
  305. mv.addObject("listMaterialItem",listMaterialItem);
  306. mv.addObject("detectinfo",detectinfo);
  307. mv.addObject("imgList",imgList);
  308. return mv;
  309. }
  310. /**
  311. * 跳转到修改检测页面
  312. *
  313. * @return
  314. */
  315. @RequiresPermissions("info:update:info")
  316. @RequestMapping(value = "/to_update")
  317. public ModelAndView toupdate(HttpServletRequest request) {
  318. ModelAndView mv = new ModelAndView("cm/inspection/update_detect");
  319. String detectId = request.getParameter("detectId");
  320. if(detectId == null || detectId.equals("")){
  321. return mv;
  322. }
  323. ComplaintDetectInfo detectinfo = complaintDetectInfoService.getDetectById(Integer.valueOf(detectId));
  324. List<ComplaintDetectImg> imgList = complaintDetectInfoService.listDetectImg(Integer.valueOf(detectId));
  325. DetectionItem detectionItem = new DetectionItem();
  326. detectionItem.setDetectId(Integer.valueOf(detectId));
  327. //查询维修配置信息
  328. List<DetectionConfig> config1 = complaintDetectInfoService.listDetectionConfig(1);
  329. List<DetectionConfig> config2 = complaintDetectInfoService.listDetectionConfig(2);
  330. List<DetectionConfig> config3 = complaintDetectInfoService.listDetectionConfig(3);
  331. List<DetectionConfig> config4 = complaintDetectInfoService.listDetectionConfig(4);
  332. List<DetectionConfig> config5 = complaintDetectInfoService.listDetectionConfig(5);
  333. List<MaterialNumberInfo> listMaterial = complaintDetectInfoService.listMaterialNumber();
  334. mv.addObject("config1",config1);
  335. mv.addObject("config2",config2);
  336. mv.addObject("config3",config3);
  337. mv.addObject("config4",config4);
  338. mv.addObject("config5",config5);
  339. //查询检测现象
  340. detectionItem.setConfigType(1);
  341. mv.addObject("detectPhenomenonList",complaintDetectInfoService.listDetectionItem(detectionItem));
  342. //查询故障原因
  343. detectionItem.setConfigType(2);
  344. mv.addObject("detectFailureCauseList",complaintDetectInfoService.listDetectionItem(detectionItem));
  345. //查询判定结果
  346. detectionItem.setConfigType(3);
  347. mv.addObject("detectResultsList",complaintDetectInfoService.listDetectionItem(detectionItem));
  348. //查询故障指向
  349. detectionItem.setConfigType(4);
  350. mv.addObject("detectPointList",complaintDetectInfoService.listDetectionItem(detectionItem));
  351. //查询原因分析
  352. detectionItem.setConfigType(5);
  353. mv.addObject("detectNalysisList",complaintDetectInfoService.listDetectionItem(detectionItem));
  354. //查询维修配件
  355. mv.addObject("listMaterialItem",complaintDetectInfoService.listMaterialItem(Integer.valueOf(detectId)));
  356. mv.addObject("listMaterial",listMaterial);
  357. mv.addObject("detectInfo",detectinfo);
  358. mv.addObject("imgList",imgList);
  359. return mv;
  360. }
  361. /**
  362. * 修改检测信息
  363. * @param request
  364. * @return
  365. * @throws Exception
  366. */
  367. @RequiresPermissions("info:update:info")
  368. @ResponseBody
  369. @RequestMapping("/update")
  370. public ResponseJson addRemark(HttpServletRequest request, ComplaintDetectInfo detectInfo) throws Exception {
  371. ResponseJson msg = new ResponseJson();
  372. if(detectInfo == null){
  373. msg.setResultCode(500);
  374. msg.setReturnCode(500);
  375. return msg;
  376. }
  377. if(detectInfo.getDetectId() == null){
  378. msg.setResultCode(500);
  379. msg.setReturnCode(500);
  380. return msg;
  381. }
  382. /*String[] componentsImgs = request.getParameterValues("componentsImg");*/
  383. String[] configli1 = request.getParameterValues("configli1");
  384. String[] configli2 = request.getParameterValues("configli2");
  385. String[] configli3 = request.getParameterValues("configli3");
  386. String[] configli4 = request.getParameterValues("configli4");
  387. String[] configli5 = request.getParameterValues("configli5");
  388. String[] configli6 = request.getParameterValues("configui6");
  389. detectInfo.setConfigli1(configli1);
  390. detectInfo.setConfigli2(configli2);
  391. detectInfo.setConfigli3(configli3);
  392. detectInfo.setConfigli4(configli4);
  393. detectInfo.setConfigli5(configli5);
  394. detectInfo.setConfigli6(configli6);
  395. Integer num = complaintDetectInfoService.updateDetectById(detectInfo);
  396. if (num < 1) {
  397. msg.setResultCode(500);
  398. msg.setReturnCode(500);
  399. } else {
  400. msg.setResultCode(200);
  401. msg.setReturnCode(200);
  402. }
  403. return msg;
  404. }
  405. /**
  406. * 修改qc检测信息
  407. * @param request
  408. * @return
  409. * @throws Exception
  410. */
  411. @RequiresPermissions("info:update:info")
  412. @ResponseBody
  413. @RequestMapping("/update_qc")
  414. public ResponseJson updateQC(HttpServletRequest request, ComplaintDetectInfo detectInfo) throws Exception {
  415. ResponseJson msg = new ResponseJson();
  416. if(detectInfo == null){
  417. msg.setResultCode(500);
  418. msg.setReturnCode(500);
  419. return msg;
  420. }
  421. if(detectInfo.getDetectId() == null){
  422. msg.setResultCode(500);
  423. msg.setReturnCode(500);
  424. return msg;
  425. }
  426. Integer num = 0;
  427. try {
  428. num = complaintDetectInfoService.updateDetectQc(detectInfo);
  429. }catch (Exception e){
  430. e.printStackTrace();
  431. }
  432. if (num < 1) {
  433. msg.setResultCode(500);
  434. msg.setReturnCode(500);
  435. } else {
  436. msg.setResultCode(200);
  437. msg.setReturnCode(200);
  438. }
  439. return msg;
  440. }
  441. /**
  442. * 修改维修内容
  443. * @param request
  444. * @return
  445. * @throws Exception
  446. */
  447. @RequiresPermissions("info:update:info")
  448. @ResponseBody
  449. @RequestMapping("/update_content")
  450. public ResponseJson update_content(HttpServletRequest request, ComplaintDetectInfo detectInfo) throws Exception {
  451. ResponseJson msg = new ResponseJson();
  452. if(detectInfo == null){
  453. msg.setResultCode(500);
  454. msg.setReturnCode(500);
  455. return msg;
  456. }
  457. if(detectInfo.getDetectId() == null){
  458. msg.setResultCode(500);
  459. msg.setReturnCode(500);
  460. return msg;
  461. }
  462. String[] configli6 = request.getParameterValues("configli6");
  463. String[] configli2 = request.getParameterValues("configli2");
  464. String[] configli3 = request.getParameterValues("configli3");
  465. String[] configli4 = request.getParameterValues("configli4");
  466. String[] configli5 = request.getParameterValues("configli5");
  467. detectInfo.setConfigli2(configli2);
  468. detectInfo.setConfigli3(configli3);
  469. detectInfo.setConfigli4(configli4);
  470. detectInfo.setConfigli5(configli5);
  471. detectInfo.setConfigli6(configli6);
  472. if(detectInfo.getDetectState() != null){
  473. if(detectInfo.getDetectState() == 32 || detectInfo.getDetectState() == 36 ){
  474. detectInfo.setMaintenanceCompletionTime(new Date());
  475. }
  476. if(detectInfo.getDetectState() == 21 ){
  477. detectInfo.setRenovationCompletionTime(new Date());
  478. }
  479. }
  480. Integer num = complaintDetectInfoService.updateDetectContent(detectInfo);
  481. if (num < 1) {
  482. msg.setResultCode(500);
  483. msg.setReturnCode(500);
  484. } else {
  485. msg.setResultCode(200);
  486. msg.setReturnCode(200);
  487. }
  488. return msg;
  489. }
  490. /**
  491. * 跳转到查看仓储进度页面
  492. *
  493. * @return
  494. */
  495. @RequiresPermissions("complete:update:complete")
  496. @RequestMapping(value = "/to_view_progress")
  497. public ModelAndView toViewProgress(HttpServletRequest request) {
  498. ModelAndView mv = new ModelAndView("cm/inspection/view_progress");
  499. String signclosedId = request.getParameter("signclosedId");
  500. if(signclosedId == null || signclosedId.equals("")){
  501. return mv;
  502. }
  503. if(Integer.valueOf(signclosedId) == 0){
  504. return mv;
  505. }
  506. List<SignclosedProductInfo> signclosedProductInfo = null;
  507. List<AwaitingSignclosedProductInfo> awaitingSignclosedProductInfo = null;
  508. ComplaintSignclosedInfo complaintSignclosedInfo = complaintSignclosedInfoService.getSignclosedById(Integer.valueOf(signclosedId));
  509. signclosedProductInfo = signclosedProductInfoService.listSignclosedById(complaintSignclosedInfo.getSignclosedId());
  510. mv.addObject("signclosedProductInfo",signclosedProductInfo);
  511. mv.addObject("signclosedInfo",complaintSignclosedInfo);
  512. mv.addObject("signclosedId",signclosedId);
  513. return mv;
  514. }
  515. /**
  516. * 跳转到查看物流信息页面
  517. *
  518. * @return
  519. */
  520. @RequestMapping(value = "/to_view_logistics")
  521. public ModelAndView toViewLogistics(HttpServletRequest request) {
  522. ModelAndView mv = new ModelAndView("cm/logistics/view_logistics");
  523. String billCode = request.getParameter("billCode");
  524. String billName = request.getParameter("billName");
  525. if(billCode == null || billCode.equals("") ||billName == null || billName.equals("")){
  526. return mv;
  527. }
  528. mv.addObject("billCode",billCode);
  529. mv.addObject("billName",billName);
  530. return mv;
  531. }
  532. /**
  533. * 跳转到修改检测完成信息页面
  534. *
  535. * @return
  536. */
  537. @RequiresPermissions("complete:update:complete")
  538. @RequestMapping(value = "/to_update_complete")
  539. public ModelAndView toUpdateComplete(HttpServletRequest request) {
  540. ModelAndView mv = new ModelAndView("cm/inspection/update_complete");
  541. String detectId = request.getParameter("detectId");
  542. if(detectId == null || detectId.equals("")){
  543. return mv;
  544. }
  545. ComplaintDetectInfo detectInfo = complaintDetectInfoService.getDetectById(Integer.valueOf(detectId));
  546. //查询维修配置信息
  547. List<DetectionConfig> config1 = complaintDetectInfoService.listDetectionConfig(1);
  548. mv.addObject("config1",config1);
  549. detectInfo.setDetectDate(new Date());
  550. mv.addObject("detectId",detectId);
  551. mv.addObject("detectInfo",detectInfo);
  552. return mv;
  553. }
  554. /**
  555. * 查询单个检测信息
  556. *
  557. * @return
  558. */
  559. @RequiresPermissions("complete:update:complete")
  560. @ResponseBody
  561. @RequestMapping(value = "/get_detect")
  562. public ResponseJson getDetect(HttpServletRequest request,Integer detectId) {
  563. ResponseJson msg = new ResponseJson();
  564. if(detectId == null){
  565. msg.setResultCode(500);
  566. msg.setReturnCode(500);
  567. return msg;
  568. }
  569. ComplaintDetectInfo detectInfo = complaintDetectInfoService.getDetectById(detectId);
  570. if(detectInfo == null){
  571. msg.setResultCode(500);
  572. msg.setReturnCode(500);
  573. return msg;
  574. }else {
  575. List<ComplaintDetectImg> detectImg = complaintDetectInfoService.listDetectImg(detectId);
  576. ComplaintSignclosedInfo signclosedInfo = complaintSignclosedInfoService.getSignclosedById(detectInfo.getSignclosedId());
  577. LogisticsInfo info = new LogisticsInfo();
  578. if(signclosedInfo != null){
  579. info.setLogisticsRstCode(signclosedInfo.getSignclosedLogistics());
  580. List<LogisticsInfo> logisticsInfos = salesOrderService.getLogisticsInfo(info);
  581. if(logisticsInfos != null && logisticsInfos.size() > 0){
  582. signclosedInfo.setSignclosedLogisticsName(logisticsInfos.get(0).getLogisticsName());
  583. }else{
  584. signclosedInfo.setSignclosedLogisticsName("其它快递");
  585. }
  586. }
  587. Admin admin = AdminUtils.getLoginAdmin();
  588. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  589. msg.addResponseKeyValue("detectImg",detectImg);
  590. msg.addResponseKeyValue("detectInfo",detectInfo);
  591. msg.addResponseKeyValue("signclosedInfo",signclosedInfo);
  592. msg.addResponseKeyValue("date",sdf.format(new Date()));//当前时间
  593. msg.addResponseKeyValue("adminName",admin.getAdminName());//当前登录人
  594. msg.setResultCode(200);
  595. msg.setReturnCode(200);
  596. return msg;
  597. }
  598. }
  599. /**
  600. * 跳转到查看客服录入客诉信息页面
  601. *
  602. * @return
  603. */
  604. @RequiresPermissions("complete:select:complete")
  605. @RequestMapping(value = "/to_customer_detail")
  606. public ModelAndView toCustomerDetail(HttpServletRequest request) {
  607. ModelAndView mv = new ModelAndView("cm/inspection/customer_detail");
  608. return mv;
  609. }
  610. /**
  611. * 检测完成
  612. * @param request
  613. * @return
  614. * @throws Exception
  615. */
  616. @RequiresPermissions("complete:update:complete")
  617. @ResponseBody
  618. @RequestMapping("/update_complete")
  619. public ResponseJson update_complete(HttpServletRequest request, ComplaintDetectInfo detectInfo) throws Exception {
  620. ResponseJson msg = new ResponseJson();
  621. if(detectInfo == null){
  622. msg.setResultCode(500);
  623. msg.setReturnCode(500);
  624. return msg;
  625. }
  626. if(detectInfo.getDetectId() == null || detectInfo.getDetectId().equals("")){
  627. msg.setResultCode(500);
  628. msg.setReturnCode(500);
  629. return msg;
  630. }
  631. String detectDate = request.getParameter("detect_date");
  632. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  633. if(detectDate != null){
  634. detectInfo.setDetectDate(format.parse(detectDate));
  635. }
  636. String[] componentsImgs = request.getParameterValues("componentsImg");
  637. String[] configli1 = request.getParameterValues("configli1");
  638. detectInfo.setConfigli1(configli1);
  639. detectInfo.setDetectCompletionTime(new Date());
  640. Integer num = complaintDetectInfoService.updateDetectById(detectInfo,componentsImgs);
  641. if (num < 1) {
  642. msg.setResultCode(500);
  643. msg.setReturnCode(500);
  644. } else {
  645. msg.setResultCode(200);
  646. msg.setReturnCode(200);
  647. }
  648. return msg;
  649. }
  650. /**
  651. * 删除检测信息
  652. * @param request
  653. * @return
  654. * @throws Exception
  655. */
  656. @RequiresPermissions("remark:add:remark")
  657. @ResponseBody
  658. @RequestMapping("/delete")
  659. public ResponseJson delete(HttpServletRequest request, Integer detectId) throws Exception {
  660. ResponseJson msg = new ResponseJson();
  661. if(detectId == null){
  662. msg.setResultCode(500);
  663. msg.setReturnCode(500);
  664. return msg;
  665. }
  666. Integer num = complaintDetectInfoService.deleteDetect(detectId);
  667. if (num < 1) {
  668. msg.setResultCode(500);
  669. msg.setReturnCode(500);
  670. } else {
  671. msg.setResultCode(200);
  672. msg.setReturnCode(200);
  673. }
  674. return msg;
  675. }
  676. /**
  677. * 查询单个检测信息
  678. * @param request
  679. * @return
  680. * @throws Exception
  681. */
  682. @RequiresPermissions("remark:add:remark")
  683. @ResponseBody
  684. @RequestMapping("/getDetectionBasis")
  685. public ResponseJson getDetectionBasis(HttpServletRequest request, Integer basisId) throws Exception {
  686. ResponseJson msg = new ResponseJson();
  687. if(basisId == null){
  688. msg.setResultCode(500);
  689. msg.setReturnCode(500);
  690. return msg;
  691. }
  692. DetectionBasis detectionBasis = new DetectionBasis();
  693. detectionBasis.setBasisId(basisId);
  694. List<DetectionBasis> listDetectionBasis = complaintDetectInfoService.listDetectionBasis(detectionBasis);
  695. if (listDetectionBasis.size() < 1) {
  696. msg.setResultCode(500);
  697. msg.setReturnCode(500);
  698. } else {
  699. msg.addResponseKeyValue("detectionBasis",listDetectionBasis.get(0));
  700. msg.setResultCode(200);
  701. msg.setReturnCode(200);
  702. }
  703. return msg;
  704. }
  705. /**
  706. * 客服确认处理结果
  707. * @param request
  708. * @return
  709. * @throws Exception
  710. */
  711. @RequiresPermissions("complete:update:complete")
  712. @ResponseBody
  713. @RequestMapping("/customer_confirm")
  714. public ResponseJson customerConfirm(HttpServletRequest request, ComplaintDetectInfo detectInfo) throws Exception {
  715. ResponseJson msg = new ResponseJson();
  716. if(detectInfo == null){
  717. msg.setResultCode(500);
  718. msg.setReturnCode(500);
  719. return msg;
  720. }
  721. if(detectInfo.getDetectId() == null || "".equals(detectInfo.getDetectId())){
  722. msg.setResultCode(500);
  723. msg.setReturnCode(500);
  724. return msg;
  725. }
  726. Admin admin = AdminUtils.getLoginAdmin();
  727. if (!complaintDetectInfoService.customerConfirm(detectInfo,admin)) {
  728. msg.setResultCode(500);
  729. msg.setReturnCode(500);
  730. } else {
  731. ComplaintDetectInfo info = complaintDetectInfoService.getDetectById(detectInfo.getDetectId());
  732. msg.setResultCode(200);
  733. msg.setReturnCode(200);
  734. msg.addResponseKeyValue("detectInfo",info);
  735. }
  736. return msg;
  737. }
  738. /**
  739. * 查询维修信息条数
  740. * @param request
  741. * @param res
  742. * @param detectInfo
  743. * @throws Exception
  744. */
  745. @ResponseBody
  746. @RequiresPermissions("detect:select:detect")
  747. @RequestMapping("/detect_excel_num")
  748. public ResponseJson salesOrderExcelNum(HttpServletRequest request,HttpServletResponse res
  749. , ComplaintDetectInfo detectInfo) throws Exception{
  750. ResponseJson msg = new ResponseJson();
  751. //根据条件查询维修数据
  752. List<ComplaintDetectInfo> detectList = complaintDetectInfoService.listComplaintDetect(detectInfo);
  753. if (detectList == null || detectList.size() == 0) {
  754. msg.setResultCode(500);
  755. msg.setReturnCode(500);
  756. return msg;
  757. }
  758. msg.setResultCode(200);
  759. msg.setReturnCode(200);
  760. return msg;
  761. }
  762. /**
  763. * 导出维修信息
  764. * @param request
  765. * @param res
  766. * @param detectInfo
  767. * @throws Exception
  768. */
  769. @RequiresPermissions("detect:select:detect")
  770. @RequestMapping("/detect_excel")
  771. public void salesOrderExcel(HttpServletRequest request,HttpServletResponse res
  772. , ComplaintDetectInfo detectInfo) throws Exception{
  773. //根据id查询订单数据
  774. List<ComplaintDetectInfo> detectList = complaintDetectInfoService.listComplaintDetect(detectInfo);
  775. /*if (detectList == null || detectList.size() == 0) {
  776. return;
  777. }*/
  778. String[] cells = {
  779. "维修编号","快递单号","产品名称","颜色","生产月份","机身条码","是否少件",
  780. "退货地区","返厂日期","购买日期","客诉日期","客诉类型",
  781. "客诉问题","售后原因","售后处理类型","工厂检测现象","是否翻新机",
  782. "故障原因","判断结果","故障指向","原因分析",
  783. "维修内容","厚膜类型","浮子类型","版本号"
  784. };
  785. exportExcel(request,res,cells,detectList);
  786. }
  787. /**
  788. * 导出订单Excel并下载
  789. * @param request
  790. * @param res
  791. * @param cells
  792. * @param detectList
  793. * @throws Exception
  794. */
  795. public void exportExcel(HttpServletRequest request,HttpServletResponse res,
  796. String[] cells,List<ComplaintDetectInfo> detectList) throws Exception {
  797. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  798. //创建一个workbook,对应一个Excel文件
  799. HSSFWorkbook wb = new HSSFWorkbook();
  800. //在workbook中添加一个sheet,对应Excel中的一个sheet
  801. HSSFSheet sheet = wb.createSheet("导出维修");
  802. //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
  803. HSSFRow row = sheet.createRow((int) 0);
  804. //创建单元格,设置值表头,设置表头居中
  805. HSSFCellStyle style = wb.createCellStyle();
  806. //居中格式
  807. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  808. //设置表头
  809. if (cells == null || cells.length == 0) {
  810. return;
  811. }
  812. //循环设置表头
  813. HSSFCell cell = null;
  814. for (int i = 0;i < cells.length;i++) {
  815. String name = cells[i];
  816. cell = row.createCell(i);
  817. cell.setCellValue(name);
  818. cell.setCellStyle(style);
  819. }
  820. for (int i = 0; i < detectList.size(); i++) {
  821. row = sheet.createRow((int) i + 1);
  822. ComplaintDetectInfo detect = detectList.get(i);
  823. String detectFilmType = "";
  824. if(detect.getDetectFilmType() != null){
  825. switch (detect.getDetectFilmType()) {
  826. case 1:detectFilmType = "圆";break;
  827. case 2:detectFilmType = "扁";break;
  828. }
  829. }
  830. String detectIsRefurbishing = "";
  831. if(detect.getDetectIsRefurbishing() != null){
  832. switch (detect.getDetectIsRefurbishing()) {
  833. case 1:detectIsRefurbishing = "是";break;
  834. case 2:detectIsRefurbishing = "否";break;
  835. }
  836. }
  837. String detectFloatType = "";
  838. if(detect.getDetectFloatType() != null){
  839. switch (detect.getDetectFloatType()) {
  840. case 1:detectFloatType = "长";break;
  841. case 2:detectFloatType = "短";break;
  842. }
  843. }
  844. String signclosedIsWhetherLess = "";
  845. if(detect.getSignclosedIsWhetherLess() != null){
  846. switch (detect.getSignclosedIsWhetherLess()) {
  847. case 1:signclosedIsWhetherLess = "是";break;
  848. case 2:signclosedIsWhetherLess = "否";break;
  849. }
  850. }
  851. // 创建单元格,设置值
  852. row.createCell(0).setCellValue(detect.getDetectNumber()==null?"":detect.getDetectNumber());
  853. row.createCell(1).setCellValue(detect.getLogisticsNumber()==null?"":detect.getLogisticsNumber());
  854. row.createCell(2).setCellValue(detect.getProductName()==null?"":detect.getProductName());
  855. row.createCell(3).setCellValue(detect.getColorName()==null?"":detect.getColorName());
  856. row.createCell(4).setCellValue(detect.getDetectProduction()==null?"":detect.getDetectProduction());
  857. row.createCell(5).setCellValue(detect.getDetectFuselageBarcode()==null?"":detect.getDetectFuselageBarcode());
  858. row.createCell(6).setCellValue(signclosedIsWhetherLess);
  859. StringBuffer area = new StringBuffer(" ");
  860. if(detect.getSignclosedAddrProvincesName() == null || detect.getSignclosedAddrProvincesName().equals("")){
  861. area.append("");
  862. }else{
  863. area.append(detect.getSignclosedAddrProvincesName());
  864. }
  865. if(detect.getSignclosedAddrProvincesName() == null || detect.getSignclosedAddrProvincesName().equals("")){
  866. area.append("");
  867. }else{
  868. area.append("-"+detect.getSignclosedAddrProvincesName());
  869. }
  870. if(detect.getSignclosedAddrCityName() == null || detect.getSignclosedAddrCityName().equals("")){
  871. area.append("");
  872. }else{
  873. area.append("-"+detect.getSignclosedAddrCityName());
  874. }
  875. row.createCell(7).setCellValue(area.toString());
  876. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  877. if(detect.getSignclosedDate()==null){
  878. row.createCell(8).setCellValue( "");
  879. }else{
  880. row.createCell(8).setCellValue(sdf.format(detect.getSignclosedDate()));
  881. }
  882. if(detect.getSalesTime()==null){
  883. row.createCell(9).setCellValue("");
  884. }else{
  885. row.createCell(9).setCellValue(sdf.format(detect.getSalesTime()));
  886. }
  887. if(detect.getCustomerCreateTime()==null){
  888. row.createCell(10).setCellValue("");
  889. }else{
  890. row.createCell(10).setCellValue(sdf.format(detect.getCustomerCreateTime()));
  891. }
  892. row.createCell(11).setCellValue(detect.getProcTypeName()==null?"":detect.getProcTypeName());
  893. row.createCell(12).setCellValue(detect.getQuestionTitle()==null?"":detect.getQuestionTitle());
  894. row.createCell(13).setCellValue(detect.getDescribeHandleDesc()==null?"":detect.getDescribeHandleDesc());
  895. row.createCell(14).setCellValue(detect.getProcMethodName()==null?"":detect.getProcMethodName());
  896. row.createCell(15).setCellValue(detect.getDetectPhenomenon()==null?"":detect.getDetectPhenomenon());
  897. row.createCell(16).setCellValue(detectIsRefurbishing);
  898. row.createCell(17).setCellValue(detect.getDetectFailureCause()==null?"":detect.getDetectFailureCause());
  899. row.createCell(18).setCellValue(detect.getDetectResults()==null?"":detect.getDetectResults());
  900. row.createCell(19).setCellValue(detect.getDetectPoint()==null?"":detect.getDetectPoint());
  901. row.createCell(20).setCellValue(detect.getDetectNalysis()==null?"":detect.getDetectNalysis());
  902. row.createCell(21).setCellValue(detect.getDetectContent()==null?"":detect.getDetectContent());
  903. row.createCell(22).setCellValue(detectFilmType);
  904. row.createCell(23).setCellValue(detectFloatType);
  905. row.createCell(24).setCellValue(detect.getDetectVersionNumber()==null?"":detect.getDetectVersionNumber());
  906. }
  907. //下载导出订单Excel
  908. downloadOrderExcel(res,wb);
  909. }
  910. /**
  911. * 下载导出订单Excel
  912. * @param res
  913. * @param wb
  914. * @throws Exception
  915. */
  916. public void downloadOrderExcel(HttpServletResponse res, HSSFWorkbook wb) throws Exception{
  917. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  918. String fileName = format.format(new Date()) + "维修报表";
  919. ByteArrayOutputStream os = new ByteArrayOutputStream();
  920. wb.write(os);
  921. byte[] content = os.toByteArray();
  922. InputStream is = new ByteArrayInputStream(content);
  923. // 设置response参数,可以打开下载页面
  924. res.reset();
  925. res.setContentType("application/vnd.ms-excel;charset=utf-8");
  926. res.setHeader("Content-Disposition", "attachment;filename="
  927. + new String((fileName + ".xls").getBytes(), "iso-8859-1"));
  928. ServletOutputStream out = res.getOutputStream();
  929. BufferedInputStream bis = null;
  930. BufferedOutputStream bos = null;
  931. try {
  932. bis = new BufferedInputStream(is);
  933. bos = new BufferedOutputStream(out);
  934. byte[] buff = new byte[2048];
  935. int bytesRead;
  936. // Simple read/write loop.
  937. while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
  938. bos.write(buff, 0, bytesRead);
  939. }
  940. } catch (Exception e) {
  941. // TODO: handle exception
  942. e.printStackTrace();
  943. } finally {
  944. if (bis != null)
  945. bis.close();
  946. if (bos != null)
  947. bos.close();
  948. }
  949. }
  950. /**
  951. * 进入导出每日检测页面
  952. */
  953. @RequestMapping(value = "/to_download_detection")
  954. public ModelAndView toDownloadDetection(HttpServletRequest request) {
  955. ModelAndView mv = new ModelAndView("cm/inspection/download_detection");
  956. return mv;
  957. }
  958. /**
  959. * 导出维修信息
  960. * @param request
  961. * @param res
  962. * @param detectInfo
  963. * @throws Exception
  964. */
  965. @RequestMapping("/download_detection")
  966. public void downloadDetection(HttpServletRequest request,HttpServletResponse res
  967. , ComplaintDetectInfo detectInfo) throws Exception{
  968. //根据id查询订单数据
  969. if((detectInfo.getStartTime() == null || detectInfo.getStartTime().equals("")) && (detectInfo.getEndTime() == null || detectInfo.getEndTime().equals(""))){
  970. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  971. Calendar date = Calendar.getInstance();
  972. date.setTime(new Date());
  973. detectInfo.setTodayTime(sdf.format(date.getTime()));
  974. }
  975. List<ComplaintDetectInfo> detectList = complaintDetectInfoService.listComplaintDetect(detectInfo);
  976. /*if (detectList == null || detectList.size() == 0) {
  977. return;
  978. }*/
  979. String[] cells = {
  980. "维修编号","快递单号","产品简称","产品颜色","生产月份","机身条码","是否少件",
  981. "退货地区","返厂日期","售后处理类型","工厂检测现象","是否翻新机","厚膜类型","浮子类型","版本号","检测日期"
  982. };
  983. exportExcel2(request,res,cells,detectList);
  984. }
  985. /**
  986. * 导出订单Excel并下载
  987. * @param request
  988. * @param res
  989. * @param cells
  990. * @param detectList
  991. * @throws Exception
  992. */
  993. public void exportExcel2(HttpServletRequest request,HttpServletResponse res,
  994. String[] cells,List<ComplaintDetectInfo> detectList) throws Exception {
  995. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  996. //创建一个workbook,对应一个Excel文件
  997. HSSFWorkbook wb = new HSSFWorkbook();
  998. //在workbook中添加一个sheet,对应Excel中的一个sheet
  999. HSSFSheet sheet = wb.createSheet("导出维修");
  1000. //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
  1001. HSSFRow row = sheet.createRow((int) 0);
  1002. //创建单元格,设置值表头,设置表头居中
  1003. HSSFCellStyle style = wb.createCellStyle();
  1004. //居中格式
  1005. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  1006. //设置表头
  1007. if (cells == null || cells.length == 0) {
  1008. return;
  1009. }
  1010. //循环设置表头
  1011. HSSFCell cell = null;
  1012. for (int i = 0;i < cells.length;i++) {
  1013. String name = cells[i];
  1014. cell = row.createCell(i);
  1015. cell.setCellValue(name);
  1016. cell.setCellStyle(style);
  1017. }
  1018. for (int i = 0; i < detectList.size(); i++) {
  1019. row = sheet.createRow((int) i + 1);
  1020. ComplaintDetectInfo detect = detectList.get(i);
  1021. String detectFilmType = "";
  1022. if(detect.getDetectFilmType() != null){
  1023. switch (detect.getDetectFilmType()) {
  1024. case 1:detectFilmType = "圆";break;
  1025. case 2:detectFilmType = "扁";break;
  1026. }
  1027. }
  1028. String detectIsRefurbishing = "";
  1029. if(detect.getDetectIsRefurbishing() != null){
  1030. switch (detect.getDetectIsRefurbishing()) {
  1031. case 1:detectIsRefurbishing = "是";break;
  1032. case 2:detectIsRefurbishing = "否";break;
  1033. }
  1034. }
  1035. String detectFloatType = "";
  1036. if(detect.getDetectFloatType() != null){
  1037. switch (detect.getDetectFloatType()) {
  1038. case 1:detectFloatType = "长";break;
  1039. case 2:detectFloatType = "短";break;
  1040. }
  1041. }
  1042. String signclosedIsWhetherLess = "";
  1043. if(detect.getSignclosedIsWhetherLess() != null){
  1044. switch (detect.getSignclosedIsWhetherLess()) {
  1045. case 1:signclosedIsWhetherLess = "是";break;
  1046. case 2:signclosedIsWhetherLess = "否";break;
  1047. }
  1048. }
  1049. // 创建单元格,设置值
  1050. row.createCell(0).setCellValue(detect.getDetectNumber()==null?"":detect.getDetectNumber());
  1051. row.createCell(1).setCellValue(detect.getLogisticsNumber()==null?"":detect.getLogisticsNumber());
  1052. row.createCell(2).setCellValue(detect.getProductAbbreviation()==null?"":detect.getProductAbbreviation());
  1053. row.createCell(3).setCellValue(detect.getColorName()==null?"":detect.getColorName());
  1054. row.createCell(4).setCellValue(detect.getDetectProduction()==null?"":detect.getDetectProduction());
  1055. row.createCell(5).setCellValue(detect.getDetectFuselageBarcode()==null?"":detect.getDetectFuselageBarcode());
  1056. row.createCell(6).setCellValue(signclosedIsWhetherLess);
  1057. StringBuffer area = new StringBuffer(" ");
  1058. if(detect.getSignclosedAddrProvincesName() == null || detect.getSignclosedAddrProvincesName().equals("")){
  1059. area.append("");
  1060. }else{
  1061. area.append(detect.getSignclosedAddrProvincesName());
  1062. }
  1063. if(detect.getSignclosedAddrCityName() == null || detect.getSignclosedAddrCityName().equals("")){
  1064. area.append("");
  1065. }else{
  1066. area.append("-"+detect.getSignclosedAddrCityName());
  1067. }
  1068. row.createCell(7).setCellValue(area.toString());
  1069. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  1070. if(detect.getSignclosedDate()==null){
  1071. row.createCell(8).setCellValue( "");
  1072. }else{
  1073. row.createCell(8).setCellValue(sdf.format(detect.getSignclosedDate()));
  1074. }
  1075. /*row.createCell(9).setCellValue(detect.getProcTypeName()==null?"":detect.getProcTypeName());*/
  1076. row.createCell(9).setCellValue(detect.getProcMethodName()==null?"":detect.getProcMethodName());
  1077. row.createCell(10).setCellValue(detect.getDetectPhenomenon()==null?"":detect.getDetectPhenomenon());
  1078. row.createCell(11).setCellValue(detectIsRefurbishing);
  1079. row.createCell(12).setCellValue(detectFilmType);
  1080. row.createCell(13).setCellValue(detectFloatType);
  1081. row.createCell(14).setCellValue(detect.getDetectVersionNumber()==null?"":detect.getDetectVersionNumber());
  1082. if(detect.getDetectPrintTime()==null){
  1083. row.createCell(15).setCellValue( "");
  1084. }else{
  1085. row.createCell(15).setCellValue(sdf.format(detect.getDetectPrintTime()));
  1086. }
  1087. if(detect.getDetectIsDownload() == 1){
  1088. //修改为已打印
  1089. ComplaintDetectInfo info = new ComplaintDetectInfo();
  1090. info.setDetectId(detect.getDetectId());
  1091. info.setDetectIsDownload(2);
  1092. complaintDetectInfoService.perfectDetect(info);
  1093. }
  1094. }
  1095. //下载导出订单Excel
  1096. downloadOrderExcel(res,wb);
  1097. }
  1098. /**
  1099. * 修改打印状态
  1100. *
  1101. * @return
  1102. */
  1103. @ResponseBody
  1104. @RequestMapping(value = "/update_print")
  1105. public ResponseJson updatePrint(HttpServletRequest request,ComplaintDetectInfo complaintDetectInfo){
  1106. ResponseJson msg = new ResponseJson();
  1107. if(complaintDetectInfo == null){
  1108. msg.setResultCode(500);
  1109. msg.setReturnCode(500);
  1110. return msg;
  1111. }
  1112. complaintDetectInfo.setDetectIsPrint(2);
  1113. complaintDetectInfo.setDetectPrintTime(new Date());
  1114. Integer num = complaintDetectInfoService.updatePrint(complaintDetectInfo);
  1115. if (num < 1) {
  1116. msg.setResultCode(500);
  1117. msg.setReturnCode(500);
  1118. } else {
  1119. msg.setResultCode(200);
  1120. msg.setReturnCode(200);
  1121. }
  1122. return msg;
  1123. }
  1124. /**
  1125. * 修改报废状态
  1126. *
  1127. * @return
  1128. */
  1129. @ResponseBody
  1130. @RequestMapping(value = "/update_scrap")
  1131. public ResponseJson updateScrap(HttpServletRequest request,ComplaintDetectInfo complaintDetectInfo){
  1132. ResponseJson msg = new ResponseJson();
  1133. if(complaintDetectInfo == null){
  1134. msg.setResultCode(500);
  1135. msg.setReturnCode(500);
  1136. return msg;
  1137. }
  1138. complaintDetectInfo.setScrapCompletionTime(new Date());
  1139. Integer num = complaintDetectInfoService.updatePrint(complaintDetectInfo);
  1140. if (num < 1) {
  1141. msg.setResultCode(500);
  1142. msg.setReturnCode(500);
  1143. } else {
  1144. msg.setResultCode(200);
  1145. msg.setReturnCode(200);
  1146. }
  1147. return msg;
  1148. }
  1149. /**
  1150. * 修改是否下单状态
  1151. *
  1152. * @return
  1153. */
  1154. /*@ResponseBody
  1155. @RequestMapping(value = "/update_placeorder")
  1156. public ResponseJson updatePlaceorder(HttpServletRequest request,ComplaintDetectInfo complaintDetectInfo){
  1157. ResponseJson msg = new ResponseJson();
  1158. if(complaintDetectInfo == null){
  1159. msg.setResultCode(500);
  1160. msg.setReturnCode(500);
  1161. return msg;
  1162. }
  1163. Integer num = complaintDetectInfoService.updatePrint(complaintDetectInfo);
  1164. if (num < 1) {
  1165. msg.setResultCode(500);
  1166. msg.setReturnCode(500);
  1167. } else {
  1168. msg.setResultCode(200);
  1169. msg.setReturnCode(200);
  1170. }
  1171. return msg;
  1172. }*/
  1173. /**
  1174. * 客诉 - 查询维修处理列表
  1175. * @param request
  1176. * @return
  1177. */
  1178. @RequiresPermissions("detect:Repair:detect")
  1179. @RequestMapping("/detect_repair_list")
  1180. public ModelAndView detectRepairList(HttpServletRequest request,
  1181. @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
  1182. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  1183. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum,
  1184. ComplaintDetectInfo detect) throws ParseException {
  1185. ModelAndView mv = new ModelAndView("cm/inspection/detect_repair_list");
  1186. detect.setDetectSource(2);
  1187. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  1188. // 封装请求数据
  1189. PageRequest<ComplaintDetectInfo> pageRequest = new PageRequest<>(detect, pageNO, pageSize, totalNum == 0);
  1190. // 查询订单列表
  1191. PagedResult<ComplaintDetectInfo> result = complaintDetectInfoService.listComplaintDetect(pageRequest);
  1192. if (totalNum != 0) {
  1193. result.setTotal(totalNum);
  1194. }
  1195. //获取所有产品类型
  1196. ProductType productType = new ProductType();
  1197. List<ProductType> productTypeList = productService.listProductType(productType);
  1198. mv.addObject("productTypeList",productTypeList);
  1199. Product product = new Product();
  1200. List<Product> productList = productService.listProductAndColorAndfittings(product);
  1201. mv.addObject("productList",productList);
  1202. //查询业务员
  1203. Admin admin = new Admin();
  1204. admin.setAdminDept(15);
  1205. List<Admin> listAdmin = sysMapper.listAdmin(admin);
  1206. mv.addObject("listAdmin",listAdmin);
  1207. ProcType procType = new ProcType();
  1208. List<ProcType> procTypeList = new ArrayList<>();
  1209. procType.setProcTypeStatus(1);
  1210. procTypeList = procTypeService.getProcTypeList(procType);
  1211. mv.addObject("procTypeList",procTypeList);
  1212. StitchAttrUtil.getSa().setModelAndView(detect, mv, "/admin/detect/detect_repair_list", result);
  1213. return mv;
  1214. }
  1215. /**
  1216. * 跳转到完善客户信息页面
  1217. *
  1218. * @return
  1219. */
  1220. @RequiresPermissions("info:update:info")
  1221. @RequestMapping(value = "/to_perfect_detect")
  1222. public ModelAndView toPerfectDetect(HttpServletRequest request) {
  1223. ModelAndView mv = new ModelAndView("cm/inspection/perfect_detect");
  1224. String detectId = request.getParameter("detectId");
  1225. if(detectId == null || detectId.equals("")){
  1226. return mv;
  1227. }
  1228. ComplaintDetectInfo detectinfo = complaintDetectInfoService.getDetectById(Integer.valueOf(detectId));
  1229. Product product = new Product();
  1230. List<Product> productList = productService.listProductAndColorAndfittings(product);
  1231. ProductColor color = new ProductColor();
  1232. color.setColorProductId(detectinfo.getProductId());
  1233. List<ProductColor> productColorList = productService.listProduceColor(color);
  1234. mv.addObject("productColorList",productColorList);
  1235. mv.addObject("productList",productList);
  1236. //查询客诉问题
  1237. ComplaintQuestionInfo complaintQuestionInfo = new ComplaintQuestionInfo();
  1238. complaintQuestionInfo.setDetectComplaintType(1);
  1239. List<ComplaintQuestionInfo> listComplaintQuestionInfo = complaintQuestionInfoMapper.listComplaintQuestionInfo(complaintQuestionInfo);
  1240. //查询业务员
  1241. Admin admin = new Admin();
  1242. admin.setAdminDept(15);
  1243. List<Admin> listAdmin = sysMapper.listAdmin(admin);
  1244. List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
  1245. mv.addObject("companyInfoList",companyInfoList);
  1246. mv.addObject("listComplaintQuestionInfo",listComplaintQuestionInfo);
  1247. mv.addObject("listAdmin",listAdmin);
  1248. mv.addObject("detectId",detectId);
  1249. mv.addObject("detectinfo",detectinfo);
  1250. return mv;
  1251. }
  1252. /**
  1253. * 完善客户信息
  1254. * @param request
  1255. * @return
  1256. * @throws Exception
  1257. */
  1258. @RequiresPermissions("info:update:info")
  1259. @ResponseBody
  1260. @RequestMapping("/perfect_detect")
  1261. public ResponseJson perfectDetect(HttpServletRequest request, ComplaintDetectInfo detectInfo) throws Exception {
  1262. ResponseJson msg = new ResponseJson();
  1263. if(detectInfo == null){
  1264. msg.setResultCode(500);
  1265. msg.setReturnCode(500);
  1266. return msg;
  1267. }
  1268. if(detectInfo.getDetectId() == null){
  1269. msg.setResultCode(500);
  1270. msg.setReturnCode(500);
  1271. return msg;
  1272. }
  1273. Calendar date = Calendar.getInstance();
  1274. date.setTime(new Date());
  1275. boolean fl = false;
  1276. for (int i = 1 ; i <= 3; i++){
  1277. date.set(Calendar.DATE, date.get(Calendar.DATE) + i);
  1278. int week = date.get(Calendar.DAY_OF_WEEK);//1--7的值,对应:星期日,星期一,星期二,星期三....星期六
  1279. if(week == 1){
  1280. fl = true;
  1281. }
  1282. date.set(Calendar.DATE, date.get(Calendar.DATE) - i);
  1283. }
  1284. if(fl){
  1285. date.set(Calendar.DATE, date.get(Calendar.DATE) + 4);
  1286. }else{
  1287. date.set(Calendar.DATE, date.get(Calendar.DATE) + 3);
  1288. }
  1289. detectInfo.setMaintenanceCutTime(date.getTime());
  1290. detectInfo.setDetectState(1);
  1291. Integer num = complaintDetectInfoService.perfectDetect(detectInfo);
  1292. if (num < 1) {
  1293. msg.setResultCode(500);
  1294. msg.setReturnCode(500);
  1295. } else {
  1296. msg.setResultCode(200);
  1297. msg.setReturnCode(200);
  1298. }
  1299. return msg;
  1300. }
  1301. /**
  1302. * 跳转到完善客户信息页面
  1303. *
  1304. * @return
  1305. */
  1306. @RequiresPermissions("info:update:info")
  1307. @RequestMapping(value = "/to_add_config")
  1308. public ModelAndView toAddConfig(HttpServletRequest request) {
  1309. ModelAndView mv = new ModelAndView("cm/inspection/add_config");
  1310. return mv;
  1311. }
  1312. /**
  1313. * 添加维修基础信息
  1314. * @param request
  1315. * @return
  1316. * @throws Exception
  1317. */
  1318. @RequiresPermissions("info:update:info")
  1319. @ResponseBody
  1320. @RequestMapping("/add_config")
  1321. public ResponseJson perfectDetect(HttpServletRequest request) throws Exception {
  1322. ResponseJson msg = new ResponseJson();
  1323. String type = request.getParameter("type");
  1324. String name = request.getParameter("name");
  1325. if(type == null || name == null){
  1326. msg.setResultCode(500);
  1327. msg.setReturnCode(500);
  1328. return msg;
  1329. }
  1330. int num = 0;
  1331. if(Integer.valueOf(type) == 6){
  1332. MaterialNumberInfo materialNumberInfo = new MaterialNumberInfo();
  1333. materialNumberInfo.setMaterialName(name);
  1334. materialNumberInfo.setMaterialType(1);
  1335. num = complaintDetectInfoService.addMaterial(materialNumberInfo);
  1336. }else{
  1337. DetectionConfig detectionConfig = new DetectionConfig();
  1338. detectionConfig.setConfigDetectContent(name);
  1339. detectionConfig.setConfigType(Integer.valueOf(type));
  1340. num = complaintDetectInfoService.addConfig(detectionConfig);
  1341. }
  1342. if (num < 1) {
  1343. msg.setResultCode(500);
  1344. msg.setReturnCode(500);
  1345. } else {
  1346. msg.setResultCode(200);
  1347. msg.setReturnCode(200);
  1348. }
  1349. return msg;
  1350. }
  1351. /**
  1352. * 跳转到统计页面
  1353. * @return
  1354. */
  1355. @RequiresPermissions("detect:statistics:detect")
  1356. @RequestMapping(value = "/detect_statistics")
  1357. public ModelAndView detectStatistics(HttpServletRequest request) {
  1358. ModelAndView mv = new ModelAndView("cm/inspection/detect_statistics");
  1359. //类型 检测类别1工厂检测现象2. 故障原因3. 判定结果4. 故障指向5. 原因分析
  1360. DetectionConfig detectionConfig = new DetectionConfig();
  1361. detectionConfig.setConfigType(3);
  1362. List<DetectionConfig> criticalResultList = detectStatisticService.getDetectConfigByTypeList(detectionConfig);
  1363. detectionConfig.setConfigType(2);
  1364. List<DetectionConfig> causeIssueList = detectStatisticService.getDetectConfigByTypeList(detectionConfig);
  1365. detectionConfig.setConfigType(5);
  1366. List<DetectionConfig> causeAnalysisList = detectStatisticService.getDetectConfigByTypeList(detectionConfig);
  1367. mv.addObject("criticalResultList",criticalResultList);
  1368. mv.addObject("causeIssueList",causeIssueList);
  1369. mv.addObject("causeAnalysisList",causeAnalysisList);
  1370. return mv;
  1371. }
  1372. /**
  1373. * 报表 - 本月故障机器
  1374. * @param request
  1375. * @return
  1376. * @throws Exception
  1377. */
  1378. @ResponseBody
  1379. @RequiresPermissions("detect:statistics:detect")
  1380. @RequestMapping("/detect_statistics_data")
  1381. public ResponseJson detectStatisticsData(HttpServletRequest request){
  1382. ResponseJson msg = ResponseJson.getSUCCESS();
  1383. List<ComplaintDetectInfo> complaintDetectInfoList = detectStatisticService.getAllMalfunctionByMonth();
  1384. msg.addResponseKeyValue("complaintDetectInfoList",complaintDetectInfoList);
  1385. return msg;
  1386. }
  1387. /**
  1388. * 报表 - 按照各个检测类型分类统计固定生产时间内,机器损坏数量
  1389. * @param request
  1390. * @return
  1391. * @throws Exception
  1392. */
  1393. @ResponseBody
  1394. @RequiresPermissions("detect:statistics:detect")
  1395. @RequestMapping("/detect_statistics_one")
  1396. public ResponseJson detectStatisticsOne(HttpServletRequest request, DetectStatistics detectStatistics){
  1397. ResponseJson msg = ResponseJson.getSUCCESS();
  1398. // detectStatistics.setBeginTime("2019-02");
  1399. //生产年份
  1400. List<DetectStatistics> detectProductionList = detectStatisticService.getDetectProductionList(detectStatistics);
  1401. //配置
  1402. List<DetectStatistics> detectConfigList = detectStatisticService.getDetectConfigList(detectStatistics);
  1403. List<Map> list = new ArrayList<>();
  1404. List<DetectStatistics> detectList = detectStatisticService.getDetectList(detectStatistics);
  1405. List<Integer> cinfigList = new ArrayList<>();
  1406. for (int i=0; i<detectConfigList.size(); i++) {
  1407. Map map = new HashMap();
  1408. int[] num = new int[detectProductionList.size()];
  1409. for (int k=0; k<detectProductionList.size(); k++){
  1410. boolean flag = false;
  1411. for (int j = 0; j <detectList.size() ; j++) {
  1412. if(detectProductionList.get(k).getDetectProduction().equals(detectList.get(j).getDetectProduction())
  1413. && Objects.equals(detectConfigList.get(i).getConfigId(), detectList.get(j).getConfigId())
  1414. ){
  1415. num[k] = detectList.get(j).getConfigNumber();
  1416. flag =true;
  1417. }
  1418. }
  1419. if(!flag){
  1420. num[k] = 0;
  1421. }
  1422. }
  1423. DetectStatistics detectConfig = detectConfigList.get(i);
  1424. map.put(detectConfig.getConfigDetectContent(),num);
  1425. list.add(map);
  1426. cinfigList.add(detectConfigList.get(i).getConfigId());
  1427. if(i >= 2){
  1428. break;
  1429. }
  1430. }
  1431. msg.addResponseKeyValue("detectConfigList",detectConfigList);
  1432. msg.addResponseKeyValue("detectProductionList",detectProductionList);
  1433. msg.addResponseKeyValue("list",list);
  1434. msg.addResponseKeyValue("cinfigList",cinfigList);
  1435. return msg;
  1436. }
  1437. }