GoodsController.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. package com.kmall.admin.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.kmall.admin.dto.GoodsDto;
  4. import com.kmall.admin.dto.GoodsPanoramaDto;
  5. import com.kmall.admin.entity.GoodsEntity;
  6. import com.kmall.admin.entity.GoodsGalleryEntity;
  7. import com.kmall.admin.entity.SysOssEntity;
  8. import com.kmall.admin.service.*;
  9. import com.kmall.admin.utils.ParamUtils;
  10. import com.kmall.admin.utils.ShiroUtils;
  11. import com.kmall.common.constant.Dict;
  12. import com.kmall.common.constant.JxlsXmlTemplateName;
  13. import com.kmall.admin.fromcomm.entity.SysUserEntity;
  14. import com.kmall.common.fileserver.util.FileManager;
  15. import com.kmall.common.utils.*;
  16. import com.kmall.common.utils.excel.ExcelExport;
  17. import com.kmall.common.utils.excel.ExcelUtil;
  18. import org.apache.commons.fileupload.FileItem;
  19. import org.apache.commons.fileupload.FileItemFactory;
  20. import org.apache.commons.fileupload.disk.DiskFileItemFactory;
  21. import org.apache.commons.lang3.StringUtils;
  22. import org.apache.shiro.authz.annotation.RequiresPermissions;
  23. import org.apache.tools.zip.ZipEntry;
  24. import org.apache.tools.zip.ZipFile;
  25. import org.slf4j.LoggerFactory;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.web.bind.annotation.*;
  28. import org.springframework.web.multipart.MultipartFile;
  29. import org.springframework.web.multipart.commons.CommonsMultipartFile;
  30. import javax.servlet.http.HttpServletRequest;
  31. import javax.servlet.http.HttpServletResponse;
  32. import java.io.*;
  33. import java.util.*;
  34. import java.util.logging.Logger;
  35. /**
  36. * Controller
  37. *
  38. * @author Scott
  39. * @email
  40. * @date 2017-08-21 21:19:49
  41. */
  42. @RestController
  43. @RequestMapping("goods")
  44. public class GoodsController {
  45. @Autowired
  46. private GoodsService goodsService;
  47. @Autowired
  48. private GoodsGalleryService goodsGalleryService;
  49. @Autowired
  50. private OfflineCartService offlineCartService;
  51. @Autowired
  52. private ExcelUtil excelUtil;
  53. @Autowired
  54. private StoreService storeService;
  55. @Autowired
  56. private SysOssService sysOssService;
  57. /**
  58. * 查看列表
  59. */
  60. @RequestMapping("/list")
  61. @RequiresPermissions("goods:list")
  62. public R list(@RequestParam Map<String, Object> params) {
  63. ParamUtils.setQueryPowerByRoleType(params, "storeKey", "merchSn", "thirdPartyMerchCode");
  64. // ParamUtils.setName(params, "name");
  65. String lastSaleTime = (String) params.get("lastSaleTime");
  66. if(org.apache.commons.lang.StringUtils.isNotEmpty(lastSaleTime)) {
  67. try {
  68. lastSaleTime = new String(lastSaleTime.getBytes("iso-8859-1"), "utf-8");
  69. } catch (Exception e) {
  70. e.printStackTrace();
  71. }
  72. lastSaleTime = DateUtils.getDate(lastSaleTime);
  73. params.put("lastSaleTime", lastSaleTime + " 00:00:00");
  74. }
  75. //查询列表数据
  76. Query query = new Query(params);
  77. query.put("isDelete", 0);
  78. List<GoodsEntity> goodsList = goodsService.queryList(query);
  79. int total = goodsService.queryTotal(query);
  80. PageUtils pageUtil = new PageUtils(goodsList, total, query.getLimit(), query.getPage());
  81. return R.ok().put("page", pageUtil);
  82. }
  83. /**
  84. * 查看信息
  85. */
  86. @RequestMapping("/info/{id}")
  87. @RequiresPermissions("goods:info")
  88. public R info(@PathVariable("id") Integer id) {
  89. GoodsEntity goods = goodsService.queryObject(id);
  90. if(goods != null) {
  91. GoodsGalleryEntity goodsGalleryEntity =goodsGalleryService.queryVideoObjectByGoodId(goods.getId());
  92. if(goodsGalleryEntity != null){
  93. goods.setVideoUrl(goodsGalleryEntity.getImgUrl());
  94. }
  95. }
  96. return R.ok().put("goods", goods);
  97. }
  98. /**
  99. * 查看信息
  100. */
  101. @RequestMapping("/infoByQuery")
  102. public R infoByQuery(@RequestParam Map<String, Object> params) {
  103. ParamUtils.setQueryPowerByRoleType(params, "storeKey", "merchSn", "thirdPartyMerchCode");
  104. ParamUtils.setName(params, "name");
  105. //查询列表数据
  106. Query query = new Query(params);
  107. query.put("isDelete", 0);
  108. List<GoodsEntity> goodsList = goodsService.queryList(query);
  109. if(goodsList != null && goodsList.size() != 0) {
  110. return R.ok().put("goods", goodsList.get(0));
  111. }
  112. return R.ok().put("goods", new GoodsEntity());
  113. }
  114. /**
  115. * 保存
  116. */
  117. @RequestMapping("/save")
  118. @RequiresPermissions("goods:save")
  119. public R save(@RequestBody GoodsEntity goods) {
  120. goodsService.save(goods);
  121. return R.ok();
  122. }
  123. /**
  124. * 修改
  125. */
  126. @RequestMapping("/update")
  127. @RequiresPermissions("goods:update")
  128. public R update(@RequestBody GoodsEntity goods) {
  129. goodsService.update(goods);
  130. return R.ok();
  131. }
  132. /**
  133. * 删除
  134. */
  135. @RequestMapping("/delete")
  136. @RequiresPermissions("goods:delete")
  137. public R delete(@RequestBody Integer[] ids) {
  138. goodsService.deleteBatch(ids);
  139. return R.ok();
  140. }
  141. /**
  142. * 查看所有列表
  143. */
  144. @RequestMapping("/queryAll")
  145. public R queryAll(@RequestParam Map<String, Object> params) {
  146. ParamUtils.setQueryPowerByRoleType(params, "storeKey", "merchSn", "thirdPartyMerchCode");
  147. params.put("isDelete", Integer.parseInt(Dict.isDelete.item_0.getItem()));
  148. params.put("isOnSale", Integer.parseInt(Dict.isOnSale.item_1.getItem()));
  149. List<GoodsEntity> list = goodsService.queryList(params);
  150. return R.ok().put("list", list);
  151. }
  152. /**
  153. * 商品回收站
  154. *
  155. * @param params
  156. * @return
  157. */
  158. @RequestMapping("/historyList")
  159. public R historyList(@RequestParam Map<String, Object> params) {
  160. ParamUtils.setQueryPowerByRoleType(params, "storeKey", "merchSn", "thirdPartyMerchCode");
  161. //查询列表数据
  162. Query query = new Query(params);
  163. query.put("isDelete", 1);
  164. List<GoodsEntity> goodsList = goodsService.queryList(query);
  165. int total = goodsService.queryTotal(query);
  166. PageUtils pageUtil = new PageUtils(goodsList, total, query.getLimit(), query.getPage());
  167. return R.ok().put("page", pageUtil);
  168. }
  169. /**
  170. * 商品从回收站恢复
  171. */
  172. @RequestMapping("/back")
  173. @RequiresPermissions("goods:back")
  174. public R back(@RequestBody Integer[] ids) {
  175. goodsService.back(ids);
  176. return R.ok();
  177. }
  178. /**
  179. * 总计
  180. */
  181. @RequestMapping("/queryTotal")
  182. public R queryTotal(@RequestParam Map<String, Object> params) {
  183. ParamUtils.setQueryPowerByRoleType(params, "storeKey", "merchSn", "thirdPartyMerchCode");
  184. params.put("isDelete", 0);
  185. int sum = goodsService.queryTotal(params);
  186. return R.ok().put("goodsSum", sum);
  187. }
  188. /**
  189. * 上架
  190. */
  191. @RequestMapping("/enSale")
  192. public R enSale(@RequestBody Integer id) {
  193. goodsService.enSale(id);
  194. return R.ok();
  195. }
  196. /**
  197. * 上架
  198. */
  199. @RequestMapping("/enSaleBatch")
  200. public R enSaleBatch(@RequestBody Integer[] ids) {
  201. goodsService.enSaleBatch(ids);
  202. return R.ok();
  203. }
  204. /**
  205. * 下架
  206. */
  207. @RequestMapping("/unSale")
  208. public R unSale(@RequestBody Integer id) {
  209. goodsService.unSale(id);
  210. return R.ok();
  211. }
  212. /**
  213. * 下架
  214. */
  215. @RequestMapping("/unSaleBatch")
  216. public R unSaleBatch(@RequestBody Integer[] ids) {
  217. goodsService.unSaleBatch(ids);
  218. return R.ok();
  219. }
  220. /**
  221. * 上传文件
  222. */
  223. @RequestMapping("/upload")
  224. @ResponseBody
  225. public R upload(@RequestParam("file") MultipartFile file) {
  226. List<GoodsDto> goodsDtoList = new ArrayList<>();//商品信息
  227. try {
  228. Map<String, Object> beans = new HashMap<String, Object>();
  229. beans.put("GoodsDtoList", goodsDtoList);
  230. if (file.isEmpty()) {
  231. return R.error("文件不能为空!");
  232. }
  233. excelUtil.readExcel(JxlsXmlTemplateName.GOODS_DTO_LIST, beans, file.getInputStream());
  234. } catch (Exception e) {
  235. e.printStackTrace();
  236. return R.error("导入失败!");
  237. }
  238. goodsService.uploadExcel(goodsDtoList,Integer.parseInt(Dict.exportDataType.item_1.getItem()));
  239. //上传文件
  240. return R.ok();
  241. }
  242. /**
  243. * 上传文件
  244. */
  245. @RequestMapping("/generalGoodsUpload")
  246. @ResponseBody
  247. public R generalGoodsUpload(@RequestParam("file") MultipartFile file) {
  248. List<GoodsDto> generalGoodsDtoList = new ArrayList<>();//商品信息
  249. try {
  250. Map<String, Object> beans = new HashMap<String, Object>();
  251. beans.put("GeneralGoodsDtoList", generalGoodsDtoList);
  252. if (file.isEmpty()) {
  253. return R.error("文件不能为空!");
  254. }
  255. excelUtil.readExcel(JxlsXmlTemplateName.GENERAL_GOODS_DTO_LIST, beans, file.getInputStream());
  256. } catch (Exception e) {
  257. e.printStackTrace();
  258. return R.error("导入失败!");
  259. }
  260. goodsService.uploadExcel(generalGoodsDtoList,Integer.parseInt(Dict.exportDataType.item_2.getItem()));
  261. //上传文件
  262. return R.ok();
  263. }
  264. @RequestMapping("/generalGoodsImgUploadByZip")
  265. @ResponseBody
  266. public R batchAddImgByZip(@RequestParam("file") MultipartFile file) throws IOException {
  267. //上传文件
  268. batchAdd(file,2);
  269. return R.ok();
  270. }
  271. @RequestMapping("/generalGoodsImgUpload")
  272. @ResponseBody
  273. public R batchAddImg(@RequestParam("file") MultipartFile file) throws IOException {
  274. //上传文件
  275. batchAdd(file,1);
  276. return R.ok();
  277. }
  278. private Map<String, Object> batchAdd(MultipartFile file, int type) throws IOException {
  279. /*
  280. *创建临时文件夹
  281. * 解压文件
  282. */
  283. String fileName = file.getOriginalFilename();
  284. String path = "/data/project/img/";
  285. File dir = new File(path);
  286. dir.mkdirs();
  287. String filePath = "/data/project/img2/";
  288. File fileDir = new File(filePath);
  289. fileDir.mkdirs();
  290. File saveFile = new File(fileDir, fileName);//将压缩包解析到指定位置
  291. List<String>list = new ArrayList<>();
  292. try {
  293. file.transferTo(saveFile);
  294. String newFilePath = filePath + fileName;
  295. File zipFile = new File(newFilePath);
  296. unZipFiles(zipFile, path,list,type);//解压文件,获取文件路径
  297. System.out.println(JSON.toJSONString(list));
  298. } catch (Exception e) {
  299. e.printStackTrace();
  300. System.out.println("解压执行失败");
  301. throw e ;
  302. }
  303. //程序结束时,删除临时文件
  304. deleteFiles(filePath);//删除压缩包文件夹
  305. deleteFiles(path);//删除解压文件夹**
  306. Map<String, Object> jsonMap = new HashMap<String, Object>();
  307. jsonMap.put("ret",list);
  308. return jsonMap;
  309. }
  310. public void unZipFiles(File srcFile, String destDirPath, List<String> list, int type) throws RuntimeException {
  311. long start = System.currentTimeMillis();
  312. // 判断源文件是否存在
  313. if (!srcFile.exists()) {
  314. throw new RuntimeException(srcFile.getPath() + "所指文件不存在");
  315. }
  316. // 开始解压
  317. ZipFile zipFile = null;
  318. try {
  319. zipFile = new ZipFile(srcFile);
  320. Enumeration<?> entries = zipFile.getEntries();
  321. while (entries.hasMoreElements()) {
  322. ZipEntry entry = (ZipEntry) entries.nextElement();
  323. System.out.println("解压" + entry.getName());
  324. // 如果是文件夹,就创建个文件夹
  325. if (entry.isDirectory()) {
  326. String dirPath = destDirPath + "/" + entry.getName();
  327. File dir = new File(dirPath);
  328. dir.mkdirs();
  329. } else {
  330. // 如果是文件,就先创建一个文件,然后用io流把内容copy过去
  331. File targetFile = new File(destDirPath + "/" + entry.getName());
  332. // 保证这个文件的父文件夹必须要存在
  333. if(!targetFile.getParentFile().exists()){
  334. }
  335. targetFile.createNewFile();
  336. // 将压缩文件内容写入到这个文件中
  337. InputStream is = zipFile.getInputStream(entry);
  338. FileOutputStream fos = new FileOutputStream(targetFile);
  339. int len;
  340. byte[] buf = new byte[1024];
  341. while ((len = is.read(buf)) != -1) {
  342. fos.write(buf, 0, len);
  343. }
  344. MultipartFile mulFileByPath = getMulFileByPath(destDirPath + "/" + entry.getName());
  345. //上传文件
  346. String url = FileManager.upload(mulFileByPath);
  347. list.add(url);
  348. if(type == 1){
  349. String sku = entry.getName().split("/")[1].split("\\.")[0];
  350. GoodsEntity goodsEntity = goodsService.queryBySku(sku);
  351. goodsEntity.setPrimaryPicUrl(url);
  352. goodsEntity.setListPicUrl(url);
  353. goodsService.updateForImgUrl(goodsEntity);
  354. }else if(type == 2){
  355. String barCode = entry.getName().split("/")[1];
  356. GoodsEntity goodsEntity = goodsService.queryByBarcode(barCode);
  357. goodsEntity.setPrimaryPicUrl(url);
  358. goodsEntity.setListPicUrl(url);
  359. goodsService.updateForImgUrl(goodsEntity);
  360. }
  361. //保存文件信息
  362. SysOssEntity ossEntity = new SysOssEntity();
  363. ossEntity.setUrl(url);
  364. ossEntity.setCreateDate(new Date());
  365. sysOssService.save(ossEntity);
  366. // 关流顺序,先打开的后关闭
  367. fos.close();
  368. is.close();
  369. }
  370. }
  371. long end = System.currentTimeMillis();
  372. System.out.println("解压完成,耗时:" + (end - start) +" ms");
  373. } catch (Exception e) {
  374. throw new RuntimeException("unzip error from ZipUtils", e);
  375. } finally {
  376. if(zipFile != null){
  377. try {
  378. zipFile.close();
  379. } catch (IOException e) {
  380. e.printStackTrace();
  381. }
  382. }
  383. }
  384. }
  385. private static MultipartFile getMulFileByPath(String picPath) {
  386. FileItem fileItem = createFileItem(picPath);
  387. MultipartFile mfile = new CommonsMultipartFile(fileItem);
  388. return mfile;
  389. }
  390. private static FileItem createFileItem(String filePath)
  391. {
  392. FileItemFactory factory = new DiskFileItemFactory(16, null);
  393. String textFieldName = "textField";
  394. int num = filePath.lastIndexOf(".");
  395. String extFile = filePath.substring(num);
  396. FileItem item = factory.createItem(textFieldName, "text/plain", true,
  397. "MyFileName" + extFile);
  398. File newfile = new File(filePath);
  399. int bytesRead = 0;
  400. byte[] buffer = new byte[8192];
  401. try
  402. {
  403. FileInputStream fis = new FileInputStream(newfile);
  404. OutputStream os = item.getOutputStream();
  405. while ((bytesRead = fis.read(buffer, 0, 8192))
  406. != -1)
  407. {
  408. os.write(buffer, 0, bytesRead);
  409. }
  410. os.close();
  411. fis.close();
  412. }
  413. catch (IOException e)
  414. {
  415. e.printStackTrace();
  416. }
  417. return item;
  418. }
  419. public void deleteFiles(String filePath) {
  420. File file = new File(filePath);
  421. if ((!file.exists()) || (!file.isDirectory())) {
  422. System.out.println("file not exist");
  423. return;
  424. }
  425. String[] tempList = file.list();
  426. File temp = null;
  427. for (int i = 0; i < tempList.length; i++) {
  428. if (filePath.endsWith(File.separator)) {
  429. temp = new File(filePath + tempList[i]);
  430. }
  431. else {
  432. temp = new File(filePath + File.separator + tempList[i]);
  433. }
  434. if (temp.isFile()) {
  435. temp.delete();
  436. }
  437. if (temp.isDirectory()) {
  438. this.deleteFiles(filePath + "/" + tempList[i]);
  439. }
  440. }
  441. // 空文件的删除
  442. file.delete();
  443. }
  444. /*@RequestMapping("/scannInfo")
  445. @RequiresPermissions("goods:scannInfo")
  446. public R scannInfo(@RequestParam Map<String, Object> params) {
  447. String goodsSn = (String)params.get("goodsSn");
  448. GoodsEntity goods = goodsService.queryObjectByGoodsSnAndBizType(goodsSn);
  449. if(goods == null) {
  450. return R.error("商品信息不存在");
  451. }
  452. List<OfflineCartEntity> cartEntityList = offlineCartService.offlineGoodsCart(goods);
  453. return R.ok().put("cartEntityList", cartEntityList);
  454. }*/
  455. @RequestMapping("/scannInfo/{prodBarcode}")
  456. @RequiresPermissions("goods:scannInfo")
  457. public R scannInfo(@PathVariable("prodBarcode")String prodBarcode) {
  458. SysUserEntity user = ShiroUtils.getUserEntity();
  459. if(user == null) {
  460. return R.error("用户登录超时,请重新登录");
  461. }
  462. if (!user.getRoleType().equalsIgnoreCase("2")) {
  463. return R.error("该操作只允许店员账户操作");
  464. }
  465. GoodsEntity goods = goodsService.queryObjectByProdBarcodeAndBizType(prodBarcode, user.getStoreId());
  466. if(goods == null) {
  467. return R.error("商品信息不存在");
  468. }
  469. return R.ok().put("goods", goods);
  470. }
  471. @RequestMapping("/details/{prodBarcode}/{storeId}")
  472. // @RequiresPermissions("goods:details") http://127.0.0.1:8080/goods/details/11111
  473. public R details(@PathVariable("prodBarcode")String prodBarcode,@PathVariable("storeId")String storeId) {
  474. SysUserEntity user = ShiroUtils.getUserEntity();
  475. if(user == null) {
  476. return R.error("用户登录超时,请重新登录");
  477. }
  478. if (!user.getRoleType().equalsIgnoreCase("2")) {
  479. return R.error("该操作只允许店员账户操作");
  480. }
  481. Map<String,Object> map = goodsService.calculateGoodsDetail(prodBarcode,storeId);
  482. if(map == null){
  483. return R.error("商品信息不存在");
  484. }
  485. return R.ok().put("goodsDetails", map.get("goods")).put("map",map);
  486. }
  487. /**
  488. * 根据商品编码或者条码查询商品信息(17.商品全景图)
  489. * @param keyword
  490. * @return
  491. */
  492. @GetMapping("/search/{keyword}")
  493. public R searchByKeyword(@PathVariable("keyword") String keyword){
  494. if (keyword == null || "".equals(keyword)){
  495. return R.error("请输入商品编码或者条码!");
  496. }
  497. GoodsPanoramaDto goodsPanoramaDto = goodsService.searchGoodsPanoramaDtoByKeyword(keyword);
  498. //GoodsEntity goods = goodsService.searchGoodsByKeyword(keyword);
  499. if (goodsPanoramaDto == null || "".equals(goodsPanoramaDto)) {
  500. return R.error("没有该商品!");
  501. }
  502. return R.ok().put("goodsPanoramaDto",goodsPanoramaDto);
  503. }
  504. /**
  505. * 所有商品模块导出
  506. * @param params 查询参数
  507. * @param response
  508. * @param request
  509. * @return
  510. */
  511. @RequiresPermissions("goods:export")
  512. @RequestMapping(value = "export")
  513. public R export(@RequestParam Map<String, Object> params, HttpServletResponse response, HttpServletRequest request) {
  514. ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
  515. params.put("isDelete", 0);
  516. String lastSaleTime = (String) params.get("lastSaleTime");
  517. if(org.apache.commons.lang.StringUtils.isNotEmpty(lastSaleTime)) {
  518. try {
  519. lastSaleTime = new String(lastSaleTime.getBytes("iso-8859-1"), "utf-8");
  520. } catch (Exception e) {
  521. e.printStackTrace();
  522. }
  523. lastSaleTime = DateUtils.getDate(lastSaleTime);
  524. params.put("lastSaleTime", lastSaleTime + " 00:00:00");
  525. }
  526. // 根据条件查询出列表
  527. List<GoodsEntity> goodsList = goodsService.queryExportList(params);
  528. ExcelExport ee = new ExcelExport("所有商品信息");
  529. String[] header = new String[]{"商户名称","第三方商户编号","商品编码","SKU","PLU","商品名称","商品英文名称","产品条码","货品业务类型","库存是否共享",
  530. "商品库存","日常价","成本价","是否上架","是否热销","录入日期","商品单位","商品税率","产品品牌","海关备案编号","计量单位","海关商品编码","国检规格型号",
  531. "原产国","海关申报要素","毛重(kg)","净重(kg)"};
  532. List<Map<String, Object>> list = new ArrayList<>();
  533. if (goodsList !=null && goodsList.size()>0){
  534. for (GoodsEntity goodsEntity : goodsList) {
  535. LinkedHashMap<String, Object> map = new LinkedHashMap<>();
  536. map.put("MerchName",goodsEntity.getMerchName());
  537. map.put("ThirdPartyMerchCode",goodsEntity.getThirdPartyMerchCode());
  538. map.put("GoodsSn",goodsEntity.getGoodsSn());
  539. map.put("Sku",goodsEntity.getSku());
  540. map.put("Plu",goodsEntity.getPlu());
  541. map.put("Name",goodsEntity.getName());
  542. map.put("EnglishName",goodsEntity.getEnglishName());
  543. String goodsBizType = goodsEntity.getGoodsBizType();
  544. Integer isStockShare = 0;
  545. if (goodsEntity.getIsStockShare()!=null){
  546. isStockShare = Integer.parseInt(goodsEntity.getIsStockShare());
  547. }
  548. map.put("ProdBarcode",goodsEntity.getProdBarcode());
  549. map.put("GoodsBizType",StringUtils.isEmpty(goodsBizType)?"":Dict.orderBizType.valueOf("item_"+goodsBizType).getItemName());
  550. map.put("IsStockShare",isStockShare==0?"否":"是");
  551. map.put("GoodsNumber",goodsEntity.getGoodsNumber());
  552. map.put("DailyPrice",goodsEntity.getDailyPrice());
  553. map.put("CostPrice",goodsEntity.getCostPrice());
  554. map.put("IsOnSale",goodsEntity.getIsOnSale()==0?"否":"是");
  555. map.put("IsHot",goodsEntity.getIsHot()==0?"否":"是");
  556. map.put("AddTime",goodsEntity.getAddTime());
  557. map.put("GoodsUnit",goodsEntity.getGoodsUnit());
  558. map.put("GoodsRate",goodsEntity.getGoodsRate());
  559. map.put("Brand",goodsEntity.getBrand());
  560. map.put("CusRecCode",goodsEntity.getCusRecCode());
  561. map.put("UnitCode",goodsEntity.getUnitCode());
  562. map.put("CusGoodsCode",goodsEntity.getCusGoodsCode());
  563. map.put("CiqProdModel",goodsEntity.getCiqProdModel());
  564. map.put("OriCntName",goodsEntity.getOriCntName());
  565. map.put("CusDeclEle",goodsEntity.getCusDeclEle());
  566. map.put("GrossWeight",goodsEntity.getGrossWeight());
  567. map.put("NetWeight",goodsEntity.getNetWeight());
  568. list.add(map);
  569. }
  570. }
  571. ee.addSheetByMap("所有商品信息", list, header);
  572. ee.export(response);
  573. return R.ok();
  574. }
  575. }