收盤:美股收高納指再攀新高 特斯拉本週大漲近28%
阿新 • • 發佈:2020-07-12
https://finance.sina.com.cn/stock/usstock/c/2020-07-11/doc-iirczymm1713563.shtml
package com.tansuo365.test1.controller.excelcontrol; import com.alibaba.excel.EasyExcel; import com.tansuo365.test1.bean.InfoData; import com.tansuo365.test1.bean.kucunbean.ChukuDetails; import com.tansuo365.test1.bean.kucunbean.WuliaoKucunRiZhi; import com.tansuo365.test1.bean.otherbean.DWuliao; import com.tansuo365.test1.bean.otherbean.ShengouDetails; import com.tansuo365.test1.bean.otherbean.ShengouZhixing; import com.tansuo365.test1.service.excelservice.ShengouDetailsExcelService; import com.tansuo365.test1.service.excelservice.WuliaoExcelService; import com.tansuo365.test1.service.kucunservice.ChukuDetailsService; import com.tansuo365.test1.service.kucunservice.WuliaoKucunRiZhiService; import com.tansuo365.test1.service.kucunservice.WuliaoKucunSearService; import com.tansuo365.test1.service.otherservice.DWuliaoService; import com.tansuo365.test1.service.otherservice.ShengouDetailsService; import com.tansuo365.test1.service.otherservice.ShengouZhixingService; import com.tansuo365.test1.service.otherservice.ShengouZongService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import javax.swing.filechooser.FileSystemView; import java.io.*; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; //import com.institutecloud.msfileservice.bean.goods_price.Pcoke; //excel匯入控制層 @RequestMapping("/excel") @RestController public class ExcelExportController { @Autowired //1.物料表匯入匯出 private WuliaoExcelService wuliaoExcelService; @Autowired //2.申購單匯出 private ShengouDetailsExcelService shengouDetailsExcelService; // @Autowired // private ShengouDetailsService shengouDetailsService; // @Autowired //3.申購執行匯出 // private ShengouZhixingService shengouZhixingService; // @Autowired //4.庫存查詢匯出 // private WuliaoKucunSearService wuliaoKucunSearService; // @Autowired // private WuliaoKucunRiZhiService wuliaoKucunRiZhiService; // @Autowired //5.用量匯出 // private ChukuDetailsService chukuDetailsService; private Class clazzz; public void setClazz(Class clazz) { clazzz = clazz; } public Class getClazz() { return clazzz; } @PostMapping("/exportExcel/{type}") public int exportExcel(HttpServletResponse response, @RequestParam(value = "downloadExcelName") String downloadExcelName, @RequestParam(value = "ids[]") Integer[] ids, @PathVariable String type) throws IOException { // 這裡注意 有同學反應使用swagger 會導致各種問題,請直接用瀏覽器或者用postman response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf-8"); // 這裡URLEncoder.encode可以防止中文亂碼 當然和easyexcel沒有關係 FileSystemView fsv = FileSystemView.getFileSystemView(); File desktopPath = fsv.getHomeDirectory(); //獲取桌面路徑 //開始獲取資料 List<InfoData> returnList = null; switch (type) { case "wuliao": setClazz(DWuliao.class); returnList = wuliaoExcelService.selectInfoDataByPKArr(ids); break; // case "shengoudan" : setClazz(ShengouDetails.class); returnList = shengouDetailsService.selectInfoDataByPKArr(ids);break; // case "shengouzhixing" : setClazz(ShengouZhixing.class); returnList = shengouZhixingService.selectInfoDataByPKArr(ids);break; // case "kucunchaxun" : setClazz(WuliaoKucunRiZhi.class); returnList = wuliaoKucunSearService.selectInfoDataByPKArr(ids);break; // case "yongliangchaxun" : setClazz(ChukuDetails.class); returnList = chukuDetailsService.selectInfoDataByPKArr(ids);break; default: break; } // 可選欄位 Set<String> excludeColumnFiledNames = new HashSet<>(); excludeColumnFiledNames.add("id"); excludeColumnFiledNames.add("p_id"); excludeColumnFiledNames.add("w_id"); excludeColumnFiledNames.add("o_id"); excludeColumnFiledNames.add("state"); excludeColumnFiledNames.add("sort"); excludeColumnFiledNames.add("order"); excludeColumnFiledNames.add("createtime"); excludeColumnFiledNames.add("updatetime"); excludeColumnFiledNames.add("cid"); excludeColumnFiledNames.add("uid"); excludeColumnFiledNames.add("delstate"); try { // String fileName = URLEncoder.encode(downloadExcelName, "UTF-8"); String fileName = downloadExcelName; OutputStream out = new FileOutputStream(desktopPath + "/" + fileName +"-"+ System.currentTimeMillis()+".xlsx"); // EasyExcel.write(out,getClazz()).autoCloseStream(Boolean.FALSE).sheet(type).doWrite(returnList); // 可選欄位 EasyExcel.write(out, getClazz()).excludeColumnFiledNames(excludeColumnFiledNames). autoCloseStream(Boolean.FALSE).sheet(type).doWrite(returnList); } catch (FileNotFoundException e) { e.printStackTrace(); return 0; } finally { } return 1; } /** * 根據選中物料類別進行匯出 * @param response * @param downloadExcelName * @param type * @param w_id 大級別分類 * @param o_id 子級別分類 * @return * @throws IOException */ @PostMapping("/exportTypeExcel/{type}") public int exportTypeExcel(HttpServletResponse response, @RequestParam(value = "downloadExcelName") String downloadExcelName, @PathVariable String type,@RequestParam("w_id")Integer w_id,@RequestParam("o_id")Integer o_id) throws IOException { // 這裡注意 有同學反應使用swagger 會導致各種問題,請直接用瀏覽器或者用postman response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf-8"); // 這裡URLEncoder.encode可以防止中文亂碼 當然和easyexcel沒有關係 FileSystemView fsv = FileSystemView.getFileSystemView(); File desktopPath = fsv.getHomeDirectory(); //獲取桌面路徑 //開始獲取資料 List<InfoData> returnList = null; switch (type) { case "wuliaoType": setClazz(DWuliao.class); returnList = wuliaoExcelService.selectInfoDataByTypeId(w_id,o_id); break; // case "shengoudan" : setClazz(ShengouDetails.class); returnList = shengouDetailsService.selectInfoDataByPKArr(ids);break; // case "shengouzhixing" : setClazz(ShengouZhixing.class); returnList = shengouZhixingService.selectInfoDataByPKArr(ids);break; // case "kucunchaxun" : setClazz(WuliaoKucunRiZhi.class); returnList = wuliaoKucunSearService.selectInfoDataByPKArr(ids);break; // case "yongliangchaxun" : setClazz(ChukuDetails.class); returnList = chukuDetailsService.selectInfoDataByPKArr(ids);break; default: break; } // 可選欄位 Set<String> excludeColumnFiledNames = new HashSet<>(); excludeColumnFiledNames.add("id"); excludeColumnFiledNames.add("p_id"); excludeColumnFiledNames.add("w_id"); excludeColumnFiledNames.add("o_id"); excludeColumnFiledNames.add("state"); excludeColumnFiledNames.add("sort"); excludeColumnFiledNames.add("order"); excludeColumnFiledNames.add("createtime"); excludeColumnFiledNames.add("updatetime"); excludeColumnFiledNames.add("cid"); excludeColumnFiledNames.add("uid"); excludeColumnFiledNames.add("delstate"); try { // String fileName = URLEncoder.encode(downloadExcelName, "UTF-8"); String fileName = downloadExcelName; OutputStream out = new FileOutputStream(desktopPath + "/" + fileName +"-"+ System.currentTimeMillis()+".xlsx"); // 可選欄位 EasyExcel.write(out, getClazz()).excludeColumnFiledNames(excludeColumnFiledNames). autoCloseStream(Boolean.FALSE).sheet(type).doWrite(returnList); } catch (FileNotFoundException e) { e.printStackTrace(); return 0; } finally { } return 1; } /** * * @param response * @param downloadExcelName * @param zongzhangid * @param type * @return * @throws IOException */ @PostMapping("/exportShengouDetailsExcel/{type}") public int exportShengouDetailsExcel(HttpServletResponse response, @RequestParam(value = "downloadExcelName") String downloadExcelName, @RequestParam(value = "zongzhangid") Integer zongzhangid, @PathVariable String type) throws IOException { // 這裡注意 有同學反應使用swagger 會導致各種問題,請直接用瀏覽器或者用postman response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf-8"); // 這裡URLEncoder.encode可以防止中文亂碼 當然和easyexcel沒有關係 FileSystemView fsv = FileSystemView.getFileSystemView(); File desktopPath = fsv.getHomeDirectory(); //獲取桌面路徑 //開始獲取資料 List<InfoData> returnList = null; switch (type) { case "shengouxx": setClazz(ShengouDetails.class); returnList = shengouDetailsExcelService.selectInfoDataByPid(zongzhangid); break; // case "shengoudan" : setClazz(ShengouDetails.class); returnList = shengouDetailsService.selectInfoDataByPKArr(ids);break; // case "shengouzhixing" : setClazz(ShengouZhixing.class); returnList = shengouZhixingService.selectInfoDataByPKArr(ids);break; // case "kucunchaxun" : setClazz(WuliaoKucunRiZhi.class); returnList = wuliaoKucunSearService.selectInfoDataByPKArr(ids);break; // case "yongliangchaxun" : setClazz(ChukuDetails.class); returnList = chukuDetailsService.selectInfoDataByPKArr(ids);break; default: break; } // 可選欄位 Set<String> excludeColumnFiledNames = new HashSet<>(); excludeColumnFiledNames.add("id"); excludeColumnFiledNames.add("zhuanye"); excludeColumnFiledNames.add("sort"); excludeColumnFiledNames.add("order"); excludeColumnFiledNames.add("createtime"); excludeColumnFiledNames.add("updatetime"); excludeColumnFiledNames.add("zongzhangid"); try { // String fileName = URLEncoder.encode(downloadExcelName, "UTF-8"); String fileName = downloadExcelName; OutputStream out = new FileOutputStream(desktopPath + "/" + fileName +"-"+ System.currentTimeMillis()+".xlsx"); // EasyExcel.write(out,getClazz()).autoCloseStream(Boolean.FALSE).sheet(type).doWrite(returnList); // 可選欄位 EasyExcel.write(out, getClazz()).excludeColumnFiledNames(excludeColumnFiledNames). autoCloseStream(Boolean.FALSE).sheet(type).doWrite(returnList); } catch (FileNotFoundException e) { e.printStackTrace(); return 0; } finally { } return 1; } ///** }
package com.tansuo365.test1.controller.excelcontrol; import com.alibaba.excel.EasyExcel; import com.github.pagehelper.PageInfo; import com.tansuo365.test1.bean.otherbean.DProject; import com.tansuo365.test1.bean.otherbean.DWuliao; import com.tansuo365.test1.bean.otherbean.ShengouDetails; import com.tansuo365.test1.listener.UploadProjectDataListener; import com.tansuo365.test1.listener.UploadSengouDetailsDataListener; import com.tansuo365.test1.listener.UploadWuliaoDataListener; import com.tansuo365.test1.service.excelservice.IAllDatasService; import com.tansuo365.test1.service.excelservice.ProjectExcelService; import com.tansuo365.test1.service.excelservice.WuliaoExcelService; import com.tansuo365.test1.service.otherservice.impl.ShengouDetailsCacheServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; //import com.institutecloud.msfileservice.bean.goods_price.Pcoke; //excel匯入控制層 /** * 適用於匯入物料 */ @RequestMapping("/excel") @RestController public class ExcelImportController { // private static final Logger LOGGER = // LoggerFactory.getLogger(ExcelImportController.class); @Autowired private WuliaoExcelService wuliaoExcelService; @Autowired private ProjectExcelService projectExcelService; @Autowired private ShengouDetailsCacheServiceImpl shengouDetailsCacheService; private IAllDatasService service; public void setService(IAllDatasService service){ this.service = service; } public IAllDatasService getService() { return service; } private Class clazzz; public void setClazz(Class clazz){ clazzz = clazz; } public Class getClazz(){ return clazzz; } /** * 通過easyexcel的讀取excel方法獲取excel資訊,通過對 * 檔案的流讀取 excel.getInputStream() * 貨品類class的設定 getClazz() *(之前通過了switch判定goodsType) * 上傳資料監聽器new UploadWuliaoDataListener(getService())spring注入進來的貨品的service層放入,在監聽器中使用service介面進行統一管理接收 * @param theExcel 前端傳入excel檔案 * @param type 匯入的型別 如wuliao,shengoudan * @param wRoot 物料根型別 * @param oSub 物料子型別 * * @throws IOException */ @PostMapping("/importExcel/{type}/{wRoot}/{oSub}") public int importExcel(@RequestParam(value = "theExcel") MultipartFile theExcel, @PathVariable String type, @PathVariable String wRoot,@PathVariable String oSub) throws IOException { // LOGGER.info("進入importExcel方法,將執行excel匯入."); Map<String,Object> paramsMap = new HashMap<>(); paramsMap.put("wRoot",wRoot); paramsMap.put("oSub",oSub); switch (type){ case "wuliao" : setClazz(DWuliao.class); setService(wuliaoExcelService); break; case "xiangmu" : setClazz(DProject.class); setService(projectExcelService); break; // case "anodePrice" : setClazz(AnodePrice.class); setService(anodePriceService);break; default:break; } try { if (type.equals("wuliao")){ EasyExcel.read(theExcel.getInputStream(), getClazz(), new UploadWuliaoDataListener(getService(),paramsMap)).sheet().doRead(); return 1; //讀取excel成功 } if (type.equals("xiangmu")){ EasyExcel.read(theExcel.getInputStream(), getClazz(), new UploadProjectDataListener(getService(),paramsMap)).sheet().doRead(); return 1; //讀取excel成功 } } catch (IOException e) { e.printStackTrace(); return 0; //讀取excel失敗 } return 0; //讀取excel失敗 } /*excel批量匯入申購詳情並回顯到頁面介面*/ @PostMapping("/importExcel/wuliaoshengoudanmingxi") public Map<String,Object> importExcel(@RequestParam(value = "theExcel") MultipartFile theExcel, @RequestParam(value="page",required=true)Integer page, @RequestParam(value="rows",required =true)Integer rows) throws IOException { setClazz(ShengouDetails.class); setService(wuliaoExcelService); List<ShengouDetails> returnShengouDetailsList = new ArrayList<>(); Map<String,Object> resultMap = new HashMap<>(); try { EasyExcel.read(theExcel.getInputStream(), getClazz(), new UploadSengouDetailsDataListener(getService(),shengouDetailsCacheService,returnShengouDetailsList)).sheet().doRead(); } catch (IOException e) { e.printStackTrace(); } List<ShengouDetails> shengouDetailsCacheList = shengouDetailsCacheService.selectAll(); shengouDetailsCacheService.delectAll(); System.out.println("資料匯出成功"+shengouDetailsCacheList); PageInfo<ShengouDetails> pageInfo = new PageInfo<ShengouDetails>(shengouDetailsCacheList); resultMap.put("rows", pageInfo.getList()); resultMap.put("total", pageInfo.getTotal()); return resultMap; } // @PostMapping("/importShengouExcel/{type}") // public int importShengouExcel(@RequestParam(value = "theExcel") MultipartFile theExcel, @PathVariable String type, // @PathVariable String wRoot,@PathVariable String oSub) throws IOException { //// LOGGER.info("進入importExcel方法,將執行excel匯入."); //// Map<String,Object> paramsMap = new HashMap<>(); //// paramsMap.put("wRoot",wRoot); //// paramsMap.put("oSub",oSub); // switch (type){ // case "shengouxx" : setClazz(ShengouDetails.class); setService(shengouDetailsExcelService);break; //// case "anodePrice" : setClazz(AnodePrice.class); setService(anodePriceService);break; // default:break; // } // try { // EasyExcel.read(theExcel.getInputStream(), getClazz(), new UploadWuliaoDataListener(getService(),paramsMap)).sheet().doRead(); // } catch (IOException e) { // e.printStackTrace(); // return 0; //讀取excel失敗 // } // return 1; //讀取excel成功 // } }
package com.tansuo365.test1.service.excelservice; import com.tansuo365.test1.bean.InfoData; import java.util.List; import java.util.Map; public interface IAllDatasService<T extends InfoData> { //刪除 int deleteByPrimaryKey(Integer id); //批量刪除 int deleteBatchByPKArr(Integer[] ids); int insert(T t); //動態插入 must int insertSelective(T t); //批量插入 new int insertBatch(List<T> list); int insertBatch(Map<String,Object> maps); //動態選擇 new List<InfoData> selectInfoDataSelective(T t); //批量獲取 List<InfoData> selectInfoDataByPKArr(Integer[] ids); //選取全部 new List<T> selectAll(); // //根據貨品型別選擇全部 // List<InfoData> selectAllByTypeForECharts(T t); //根據PK獲取貨品例項 InfoData selectByPrimaryKey(Integer id); //動態更新 must int updateByPrimaryKeySelective(T t); int updateByPrimaryKey(T t); }
package com.tansuo365.test1.service.excelservice;
import com.tansuo365.test1.bean.InfoData;
import com.tansuo365.test1.bean.otherbean.DWuliao;
import com.tansuo365.test1.bean.otherbean.ShengouDetails;
import java.util.List;
public interface WuliaoExcelService extends IAllDatasService<DWuliao>{
List<InfoData> selectInfoDataByTypeId(Integer w_id,Integer o_id);
List<ShengouDetails> batchSelectInfoDataByWuliaobianma(List<ShengouDetails> shengouDetailsList);
}
package com.tansuo365.test1.service.excelservice;
import com.tansuo365.test1.bean.InfoData;
import com.tansuo365.test1.bean.otherbean.DProject;
import com.tansuo365.test1.bean.otherbean.DWuliao;
import java.util.List;
public interface ProjectExcelService extends IAllDatasService<DProject>{
List<InfoData> selectInfoDataByTypeId(Integer w_id, Integer o_id);
}
package com.tansuo365.test1.service.otherservice.impl;
import com.tansuo365.test1.bean.otherbean.ShengouDetails;
import com.tansuo365.test1.mapper.othermapper.ShengouDetailsCacheMapper;
import com.tansuo365.test1.service.otherservice.ShengouDetailsCacheService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class ShengouDetailsCacheServiceImpl implements ShengouDetailsCacheService {
@Resource
private ShengouDetailsCacheMapper shengouDetailsCacheMapper ;
@Override
public List<ShengouDetails> selectAll() {
return shengouDetailsCacheMapper.selectAll();
}
@Override
public int delectAll() {
return shengouDetailsCacheMapper.deleteAll();
}
@Override
public void insertAll(List<ShengouDetails> shengouDetailsList) {
shengouDetailsList.forEach(shengouDetails->shengouDetailsCacheMapper.insertSelective(shengouDetails));
}
}
package com.tansuo365.test1.service.otherservice;
import com.tansuo365.test1.bean.otherbean.ShengouDetails;
import java.util.List;
public interface ShengouDetailsCacheService {
List<ShengouDetails> selectAll();
int delectAll();
void insertAll(List<ShengouDetails> shengouDetailsList);
}
package com.tansuo365.test1.controller.excelcontrol;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class WuliaoPidEntity {
private Integer wRoot;
private Integer oSub;
}
package com.tansuo365.test1.controller.kucunstuff;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.tansuo365.test1.bean.kucunbean.WeixiuDetails;
import com.tansuo365.test1.bean.kucunbean.WeixiuZong;
import com.tansuo365.test1.service.kucunservice.WeixiuDetailsService;
import com.tansuo365.test1.service.kucunservice.WeixiuZongService;
import com.tansuo365.test1.service.kucunservice.WuliaoKucunRiZhiService;
import com.tansuo365.test1.util.DateUtil;
import com.tansuo365.test1.util.StringUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@PropertySource(value = "classpath:danhao.properties")
@Api(value = "維修單相關控制層", tags = "", description = "")
@RestController
@RequestMapping("/admin/weixiudan")
public class WeixiuDanController {
@Autowired
private WeixiuZongService weixiuZongService;
@Autowired
private WeixiuDetailsService weixiuDetailsService;
@Autowired
private WuliaoKucunRiZhiService wuliaoKucunRiZhiService;
// @Autowired
// private WeixiuDetailsService weixiuDetailsService;
@Value("${danhao.weixiudan.prefix}")
private String weixiudanPrefix;
//weixiu單號生成
/**
* 獲取weixiu單號 OK
*
* @param type
* @return
* @throws Exception
*/
@Async
@RequestMapping("/getWeixiuNumber")
public ListenableFuture<String> genBillCode(String type) throws Exception {
StringBuffer billCodeStr = new StringBuffer();
billCodeStr.append(weixiudanPrefix);
billCodeStr.append(DateUtil.getCurrentDateStr());
String todayMaxWeixiuDanNumber = weixiuZongService.getTodayMaxWeixiuDanNumber();
if (todayMaxWeixiuDanNumber != null) {
billCodeStr.append(StringUtil.formatCode(todayMaxWeixiuDanNumber));
} else {
billCodeStr.append("0001");
}
return new AsyncResult<>(billCodeStr.toString());
}
@RequestMapping("/getSelective")
public Map<String, Object> getWeixiuDan(WeixiuZong weixiuZong, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
if (weixiuZong == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
PageHelper.startPage(page, rows);
List<WeixiuZong> weixiuZongsList = weixiuZongService.listWeixiuZong(weixiuZong);
PageInfo<WeixiuZong> pageInfo = new PageInfo<>(weixiuZongsList);
resultMap.put("rows", pageInfo.getList());
resultMap.put("total", pageInfo.getTotal());
return resultMap;
}
@RequestMapping("/listDetailsByZId")
public Map<String, Object> listDetailsByZongId(WeixiuDetails weixiuDetails, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
if (weixiuDetails == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
PageHelper.startPage(page, rows);
List<WeixiuDetails> weixiuDetailsList = weixiuDetailsService.listWeixiuDetailsSelective(weixiuDetails);
PageInfo<WeixiuDetails> pageInfo = new PageInfo<>(weixiuDetailsList);
resultMap.put("rows", pageInfo.getList());
resultMap.put("total", pageInfo.getTotal());
return resultMap;
}
@RequestMapping("/save")
public Map<String, Object> save(HttpSession session, WeixiuZong weixiuZong, @RequestParam("wuliaoWeixiuDetailsJson") String wuliaoWeixiuDetailsJson) {
if (weixiuZong == null || wuliaoWeixiuDetailsJson == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss")
.create();
List<WeixiuDetails> weixiuDetailsList = gson.fromJson(wuliaoWeixiuDetailsJson, new TypeToken<List<WeixiuDetails>>() {
}.getType());
weixiuZong.setChuangjianren((String) session.getAttribute("truename"));
//save時, 先儲存大表, 大表返回id後再儲存附表
int insertCode = weixiuZongService.saveZongAndDetails(weixiuZong, weixiuDetailsList);
if (insertCode > 0) {
resultMap.put("success", true);
resultMap.put("msg", "儲存成功.");
return resultMap;
} else if (insertCode == 0) {
resultMap.put("success", false);
resultMap.put("errorInfo", "儲存失敗");
return resultMap;
}else if (insertCode < -99) {
WeixiuDetails weixiuDetails = weixiuDetailsList.get((-insertCode) - 100);
resultMap.put("success", false);
resultMap.put("errorInfo", "儲存失敗,儲存維修物料[" + weixiuDetails .getMingchengguige() + "]超過現有庫存數量,請核對庫存數量再進行出庫操作.");
return resultMap;
} else {
WeixiuDetails weixiuDetails = weixiuDetailsList.get((-(insertCode) - 1));
resultMap.put("success", false);
resultMap.put("errorInfo", "儲存失敗,儲存物料[" + weixiuDetails.getMingchengguige() + "]不存在庫存中.");
return resultMap;
}
}
@RequestMapping("/update")
public Map<String, Object> update(WeixiuZong weixiuZong) {
if (weixiuZong == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
int updateCode = weixiuZongService.updateByPrimaryKeySelective(weixiuZong);
if (updateCode > 0) {
resultMap.put("success", true);
return resultMap;
} else {
resultMap.put("success", false);
return resultMap;
}
}
@RequestMapping("/delete")
@Transactional
public Map<String, Object> deleteBatch(@RequestParam("ids[]") Integer[] ids) {
Map<String, Object> resultMap = new HashMap<>();
if (ids == null) {
resultMap.put("success", false);
resultMap.put("errorInfo", "請選中條目進行刪除");
return resultMap;
}
int ziDelCode = 0;
int kucunhuifuCode = wuliaoKucunRiZhiService.insertAndDeletePosunOrWeixiuShu(ids, "weixiudan");
int code = weixiuZongService.deleteBatchByPKArr(ids); //批量刪除weixiu主表
if(code>0){
ziDelCode = weixiuDetailsService.deleteByZongIdArr(ids); //批量刪除weixiu詳細根據ids條目
}
if (code > 0 && ziDelCode > 0 && kucunhuifuCode > 0) {
resultMap.put("success", true);
} else {
resultMap.put("success", false);
}
return resultMap;
}
@RequestMapping("/repair/{weixiuzhuangtai}")
public Map<String, Object> repairBatch(@RequestParam("ids[]") Integer[] ids, @PathVariable String weixiuzhuangtai) {
Map<String, Object> resultMap = new HashMap<>();
if (ids == null) {
resultMap.put("success", false);
resultMap.put("errorInfo", "請選中條目進行操作");
return resultMap;
}
if(weixiuzhuangtai==null){
resultMap.put("success", false);
resultMap.put("errorInfo", "維修狀態異常");
return resultMap;
}
System.out.println("weixiuzhuangtai:"+weixiuzhuangtai);
//不刪除維修單主表和子表,只更改其weixiuzhuangtai欄位為'已修復'
int kucunhuifuCode = 0;
if(weixiuzhuangtai.equals("未修復")){
kucunhuifuCode = wuliaoKucunRiZhiService.insertAndDeletePosunOrWeixiuShu(ids, "weixiufu");
}else if(weixiuzhuangtai.equals("已修復")){
kucunhuifuCode = wuliaoKucunRiZhiService.insertAndDelDaohuoShu(ids, "yixiufu");
}else{
resultMap.put("success", false);
resultMap.put("errorInfo", "維修狀態異常");
return resultMap;
}
int upztCode = weixiuZongService.updateZhuangtaiByIds(ids);
int updZtCode = weixiuDetailsService.updateDZhuangtaiByZIds(ids);
if (upztCode > 0 && updZtCode > 0 && kucunhuifuCode > 0) {
resultMap.put("success", true);
return resultMap;
} else {
resultMap.put("success", false);
return resultMap;
}
}
}
package com.tansuo365.test1.service.kucunservice;
import com.tansuo365.test1.bean.kucunbean.WeixiuDetails;
import com.tansuo365.test1.bean.kucunbean.WeixiuZong;
import java.util.List;
public interface WeixiuZongService {
String getTodayMaxWeixiuDanNumber();
int deleteByPrimaryKey(Integer id);
//動態查詢維修單總表
List<WeixiuZong> listWeixiuZong(WeixiuZong weixiuZong);
int deleteBatchByPKArr(Integer[] ids);
int insertSelective(WeixiuZong weixiuZong);
//新增維修單 以及所有維修單物料
int saveZongAndDetails(WeixiuZong weixiuZong, List<WeixiuDetails> weixiuDetailsList);
WeixiuZong selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(WeixiuZong weixiuZong);
int updateZhuangtaiByIds(Integer[] ids);
}
package com.tansuo365.test1.controller.kucunstuff;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.tansuo365.test1.bean.kucunbean.TuikuDetails;
import com.tansuo365.test1.bean.kucunbean.TuikuZong;
import com.tansuo365.test1.service.kucunservice.*;
import com.tansuo365.test1.service.otherservice.HuishouZhixingService;
import com.tansuo365.test1.util.DateUtil;
import com.tansuo365.test1.util.StringUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 退庫單
*/
@PropertySource(value = "classpath:danhao.properties")
@Api(value = "退庫單相關控制層", tags = "", description = "")
@RestController
@RequestMapping("/admin/tuikudan")
public class TuikuDanController {
@Autowired
private TuikuZongService tuikuZongService;
@Autowired
private TuikuDetailsService tuikuDetailsService;
@Autowired
private ChukuZhixingService chukuZhixingService;
@Autowired
private WuliaoKucunRiZhiService wuliaoKucunRiZhiService;
@Autowired
private HuishouZhixingService huishouZhixingService;
@Autowired
private ChukuZongService chukuZongService;
// @Autowired
// private TuikuDetailsService tuikuDetailsService;
@Value("${danhao.tuikudan.prefix}")
private String tuikudanPrefix;
//到貨單號生成
/**
* 獲取tuiku單號 OK
*
* @param type
* @return
* @throws Exception
*/
@Async
@RequestMapping("/getTuikuNumber")
public ListenableFuture<String> genBillCode(String type) throws Exception {
StringBuffer billCodeStr = new StringBuffer();
billCodeStr.append(tuikudanPrefix);
billCodeStr.append(DateUtil.getCurrentDateStr());
String todayMaxTuikuDanNumber = tuikuZongService.getTodayMaxTuikuDanNumber();
if (todayMaxTuikuDanNumber != null) {
billCodeStr.append(StringUtil.formatCode(todayMaxTuikuDanNumber));
} else {
billCodeStr.append("0001");
}
return new AsyncResult<>(billCodeStr.toString());
}
@RequestMapping("/getSelective")
public Map<String, Object> getTuikuDan(TuikuZong tuikuZong, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
if (tuikuZong == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
PageHelper.startPage(page, rows);
List<TuikuZong> tuikuZongsList = tuikuZongService.listTuikuZong(tuikuZong);
PageInfo<TuikuZong> pageInfo = new PageInfo<>(tuikuZongsList);
resultMap.put("rows", pageInfo.getList());
resultMap.put("total", pageInfo.getTotal());
return resultMap;
}
@RequestMapping("/listDetailsByZId")
public Map<String, Object> listDetailsByZongId(TuikuDetails tuikuDetails, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
if (tuikuDetails == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
PageHelper.startPage(page, rows);
List<TuikuDetails> tuikuDetailsList = tuikuDetailsService.listTuikuDetailsSelective(tuikuDetails);
PageInfo<TuikuDetails> pageInfo = new PageInfo<>(tuikuDetailsList);
resultMap.put("rows", pageInfo.getList());
resultMap.put("total", pageInfo.getTotal());
return resultMap;
}
/**
* 儲存
* 1.退庫單儲存後,同時寫入出庫數量,退庫數量到出庫執行彙總
* 2.退庫單儲存後,同時寫入庫存查詢表,出庫量/退庫量,進行計算的(未退回量)
*
* @param session
* @param tuikuZong
* @param wuliaoTuikuDetailsJson
* @return
*/
@RequestMapping("/save")
public Map<String, Object> save(HttpSession session, TuikuZong tuikuZong, @RequestParam("wuliaoTuikuDetailsJson") String wuliaoTuikuDetailsJson) {
if (tuikuZong == null || wuliaoTuikuDetailsJson == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss")
.create();
List<TuikuDetails> tuikuDetailsList = gson.fromJson(wuliaoTuikuDetailsJson, new TypeToken<List<TuikuDetails>>() {
}.getType());
tuikuZong.setFounder((String) session.getAttribute("truename"));
//save時, 先儲存大表, 大表返回id後再儲存附表
int insertCode = tuikuZongService.saveZongAndDetails(tuikuZong, tuikuDetailsList);
int zhixingSaveCode = chukuZhixingService.saveTuikuBindChuku(tuikuDetailsList, tuikuZong);
if (insertCode > 0 && zhixingSaveCode > 0) {
resultMap.put("success", true);
resultMap.put("msg", "儲存成功.");
return resultMap;
} else if (insertCode == 0) {
resultMap.put("success", false);
resultMap.put("errorInfo", "儲存失敗");
return resultMap;
} else {
TuikuDetails tuikuDetails = tuikuDetailsList.get((-(insertCode) - 1));
resultMap.put("success", false);
resultMap.put("errorInfo", "儲存失敗,儲存物料[" + tuikuDetails.getMingchengguige() + "]不存在庫存中.");
return resultMap;
}
}
@RequestMapping("/update")
public Map<String, Object> update(TuikuZong tuikuZong) {
if (tuikuZong == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
int updateCode = tuikuZongService.updateByPrimaryKeySelective(tuikuZong);
if (updateCode > 0) {
resultMap.put("success", true);
return resultMap;
} else {
resultMap.put("success", false);
return resultMap;
}
}
@RequestMapping("/delete")
@Transactional
public Map<String, Object> deleteBatch(@RequestParam("ids[]") Integer[] ids) {
Map<String, Object> resultMap = new HashMap<>();
if (ids == null) {
resultMap.put("success", false);
resultMap.put("errorInfo", "請選中條目進行刪除");
return resultMap;
}
//刪除退庫綁定出庫
int ziDelCode = 0;
int delBindCode = tuikuZongService.deleteTuikuBindChuku(ids);
int delToKC = wuliaoKucunRiZhiService.insertButDeleteTuikuShu(ids);
int code = tuikuZongService.deleteBatchByPKArr(ids); //批量刪除tuiku主表
List<String> chukudans = null;
if(code>0){
//刪除之前獲取對應的出庫單號s
chukudans = tuikuDetailsService.listDuiyingChukuDan(ids);
//再刪除
ziDelCode = tuikuDetailsService.deleteByZongIdArr(ids); //批量刪除tuiku詳細根據ids條目
}
if(ziDelCode>0){
// 再判定是否還有這些對應出庫單
List<TuikuDetails> tuikuDetails = tuikuDetailsService.listByDuiyingChukudans(chukudans);
if(CollectionUtils.isEmpty(tuikuDetails)){
for(String chukudan:chukudans){
int i = chukuZongService.updateCanDeleteNotBindTuiku(chukudan);
}
}
}
if (code > 0 && ziDelCode > 0 && delBindCode > 0 && delToKC > 0) {
resultMap.put("success", true);
return resultMap;
} else {
resultMap.put("success", false);
return resultMap;
}
}
}
package com.tansuo365.test1.controller.kucunstuff;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.tansuo365.test1.bean.kucunbean.PosunDetails;
import com.tansuo365.test1.bean.kucunbean.PosunZong;
import com.tansuo365.test1.service.kucunservice.PosunDetailsService;
import com.tansuo365.test1.service.kucunservice.PosunZongService;
import com.tansuo365.test1.service.kucunservice.WuliaoKucunRiZhiService;
import com.tansuo365.test1.util.DateUtil;
import com.tansuo365.test1.util.StringUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@PropertySource(value = "classpath:danhao.properties")
@Api(value = "破損單相關控制層", tags = "", description = "")
@RestController
@RequestMapping("/admin/posundan")
public class PosunDanController {
@Autowired
private PosunZongService posunZongService;
@Autowired
private PosunDetailsService posunDetailsService;
@Autowired
private WuliaoKucunRiZhiService wuliaoKucunRiZhiService;
@Value("${danhao.posundan.prefix}")
private String posundanPrefix;
/**
* 獲取破損單號
*
* @param type
* @return
* @throws Exception
*/
@Async
@RequestMapping("/getPosunNumber")
public ListenableFuture<String> getBillCode(String type) throws Exception {
StringBuffer billCodeStr = new StringBuffer();
billCodeStr.append(posundanPrefix);
billCodeStr.append(DateUtil.getCurrentDateStr());
String todayMaxShengouDanNumber = posunZongService.getTodayMaxPosunDanNumber();
if (todayMaxShengouDanNumber != null) {
billCodeStr.append(StringUtil.formatCode(todayMaxShengouDanNumber));
} else {
billCodeStr.append("0001");
}
return new AsyncResult<>(billCodeStr.toString());
}
@RequestMapping("/getSelective")
public Map<String, Object> getPosunDan(PosunZong posunZong, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
if (posunZong == null) {
return null;
}
System.out.println("專案名稱:" + posunZong.getXiangmumingcheng());
Map<String, Object> resultMap = new HashMap<>();
PageHelper.startPage(page, rows);
List<PosunZong> posunZongsList = posunZongService.listPosunZong(posunZong);
PageInfo<PosunZong> pageInfo = new PageInfo<PosunZong>(posunZongsList);
resultMap.put("rows", pageInfo.getList());
resultMap.put("total", pageInfo.getTotal());
return resultMap;
}
/**
* 根據zongzhang總表的id查詢對應的子表資料 分頁
*
* @param page
* @param rows
* @return 根據總表id遍歷查詢詳細的物料集合
*/
@RequestMapping("/listDetailsByZId")
public Map<String, Object> listDetailsByZongId(PosunDetails posunDetails, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
if (posunDetails == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
PageHelper.startPage(page, rows);
List<PosunDetails> posunDetailsList = posunDetailsService.listPosunDetailsSelective(posunDetails);
PageInfo<PosunDetails> pageInfo = new PageInfo<PosunDetails>(posunDetailsList);
resultMap.put("rows", pageInfo.getList());
resultMap.put("total", pageInfo.getTotal());
return resultMap;
}
@RequestMapping("/save")
public Map<String, Object> save(HttpSession session, PosunZong posunZong, @RequestParam("wuliaoPosunDetailsJson") String wuliaoPosunDetailsJson) {
if (posunZong == null || wuliaoPosunDetailsJson == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss")
.create();
List<PosunDetails> posunDetailsList = gson.fromJson(wuliaoPosunDetailsJson, new TypeToken<List<PosunDetails>>() {
}.getType());
posunZong.setChuangjianren((String) session.getAttribute("truename"));
//save時,先儲存大表,大表返回id後再儲存附表
int insertCode = posunZongService.saveZongAndDetails(posunZong, posunDetailsList);
if(insertCode>0){
resultMap.put("success", true);
resultMap.put("msg", "儲存成功.");
return resultMap;
}else if(insertCode==0){
resultMap.put("success", false);
resultMap.put("errorInfo", "儲存失敗");
return resultMap;
}else if (insertCode < -99) {
PosunDetails posunDetails = posunDetailsList.get((-insertCode) - 100);
resultMap.put("success", false);
resultMap.put("errorInfo", "儲存失敗,儲存破損物料[" + posunDetails.getMingchengguige() + "]超過現有庫存數量,請核對庫存數量再進行出庫操作.");
return resultMap;
}else{
PosunDetails posunDetails = posunDetailsList.get((-(insertCode) - 1));
resultMap.put("success",false);
resultMap.put("errorInfo","儲存失敗,儲存物料["+posunDetails.getMingchengguige()+"]不存在庫存中.");
return resultMap;
}
}
@RequestMapping("/update")
public Map<String, Object> update(PosunZong posunZong) {
if (posunZong == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
int updateCode = posunZongService.updateByPrimaryKeySelective(posunZong);
if (updateCode > 0) {
resultMap.put("success", true);
return resultMap;
} else {
resultMap.put("success", false);
return resultMap;
}
}
@RequestMapping("/delete")
@Transactional
public Map<String,Object> deleteBatch(@RequestParam("ids[]") Integer[] ids){
Map<String, Object> resultMap = new HashMap<>();
if (ids == null) {
resultMap.put("success", false);
resultMap.put("errorInfo", "請選中條目進行刪除");
return resultMap;
}
int posundan = wuliaoKucunRiZhiService.insertAndDeletePosunOrWeixiuShu(ids, "posundan");
int ziDelCode = 0;
int code = posunZongService.deleteBatchByPKArr(ids); //
if(code>0){
ziDelCode = posunDetailsService.deleteByZongIdArr(ids); //批量刪除到貨詳細根據ids條目
}
if (code > 0 && ziDelCode > 0 && posundan>0) {
resultMap.put("success", true);
} else {
resultMap.put("success", false);
}
return resultMap;
}
}
package com.tansuo365.test1.controller.kucunstuff;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.tansuo365.test1.bean.kucunbean.DaohuoDetails;
import com.tansuo365.test1.bean.kucunbean.DaohuoZong;
import com.tansuo365.test1.service.kucunservice.DaohuoDetailsService;
import com.tansuo365.test1.service.kucunservice.DaohuoZongService;
import com.tansuo365.test1.service.otherservice.ShengouZhixingService;
import com.tansuo365.test1.service.kucunservice.WuliaoKucunRiZhiService;
import com.tansuo365.test1.service.kucunservice.WuliaoKucunSearService;
import com.tansuo365.test1.service.otherservice.ShengouZongService;
import com.tansuo365.test1.util.DateUtil;
import com.tansuo365.test1.util.StringUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@PropertySource(value = "classpath:danhao.properties")
@Api(value = "到貨單相關控制層", tags = "", description = "")
@RestController
@RequestMapping("/admin/daohuodan")
public class DaohuoDanController {
@Autowired
private DaohuoZongService daohuoZongService;
@Autowired
private DaohuoDetailsService daohuoDetailsService;
@Autowired
private ShengouZhixingService shengouZhixingService;
@Autowired
private WuliaoKucunSearService wuliaoKucunSearService;
@Autowired
private WuliaoKucunRiZhiService wuliaoKucunRiZhiService;
@Autowired
private ShengouZongService shengouZongService;
@Value("${danhao.daohuodan.prefix}")
private String daohuodanPrefix;
//到貨單號生成
/**
* 獲取申購單號 OK
*
* @param type
* @return
* @throws Exception
*/
@Async
@RequestMapping("/getDaohuoNumber")
public ListenableFuture<String> genBillCode(String type) throws Exception {
StringBuffer billCodeStr = new StringBuffer();
billCodeStr.append(daohuodanPrefix);
billCodeStr.append(DateUtil.getCurrentDateStr());
String todayMaxShengouDanNumber = daohuoZongService.getTodayMaxDaohuoDanNumber();
if (todayMaxShengouDanNumber != null) {
billCodeStr.append(StringUtil.formatCode(todayMaxShengouDanNumber));
} else {
billCodeStr.append("0001");
}
return new AsyncResult<>(billCodeStr.toString());
}
@RequestMapping("/getSelective")
public Map<String, Object> getDaohuoDan(DaohuoZong daohuoZong, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
if (daohuoZong == null) {
return null;
}
System.out.println("專案名稱:" + daohuoZong.getXiangmumingcheng());
Map<String, Object> resultMap = new HashMap<>();
PageHelper.startPage(page, rows);
List<DaohuoZong> daohuoZongsList = daohuoZongService.listDaohuoZong(daohuoZong);
PageInfo<DaohuoZong> pageInfo = new PageInfo<DaohuoZong>(daohuoZongsList);
resultMap.put("rows", pageInfo.getList());
resultMap.put("total", pageInfo.getTotal());
return resultMap;
}
//驗收單繫結到貨單 回填資料
@RequestMapping("/bangdingDaohuo")
public Map<String, Object> getDaohuodanById(DaohuoZong daohuoZong) {
Map<String, Object> resultMap = new HashMap<>();
// List<ShengouZong> shengouZong1 = shengouZongService.listShengouZong(shengouZong);
List<DaohuoDetails> daohuoDetailsList = daohuoDetailsService.listDaohuoDetailsByZongId(daohuoZong.getId());
// resultMap.put("shengouZong",shengouZong1.get(0));
resultMap.put("daohuoDetailsList", daohuoDetailsList);
resultMap.put("success", true);
return resultMap;
}
/**
* 根據zongzhang總表的id查詢對應的子表資料 分頁
*
* @param page
* @param rows
* @return 根據總表id遍歷查詢詳細的物料集合
*/
@RequestMapping("/listDetailsByZId")
public Map<String, Object> listDetailsByZongId(DaohuoDetails daohuoDetails, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
if (daohuoDetails == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
PageHelper.startPage(page, rows);
List<DaohuoDetails> daohuoDetailsList = daohuoDetailsService.listDaohuoDetailsSelective(daohuoDetails);
PageInfo<DaohuoDetails> pageInfo = new PageInfo<DaohuoDetails>(daohuoDetailsList);
resultMap.put("rows", pageInfo.getList());
resultMap.put("total", pageInfo.getTotal());
return resultMap;
}
/**
* 儲存申購總表+子表資料 OK
*
* @return
*/
//1.到貨單儲存後,同時寫入申購數量,到貨數量到申購執行彙總
//2.到貨單儲存後,同時寫入庫存查詢表,申購量/到貨量,進行計算的(未到貨量)
@RequestMapping("/save")
@Transactional
public Map<String, Object> save(HttpSession session, DaohuoZong daohuoZong, @RequestParam("wuliaoDaohuoDetailsJson") String wuliaoDaohuoDetailsJson) {
if (daohuoZong == null || wuliaoDaohuoDetailsJson == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss")
.create();
List<DaohuoDetails> daohuoDetailsList = gson.fromJson(wuliaoDaohuoDetailsJson, new TypeToken<List<DaohuoDetails>>() {
}.getType());
daohuoZong.setFounder((String) session.getAttribute("truename"));
//save時,先儲存大表,大表返回id後再儲存附表
int insertCode = daohuoZongService.saveZongAndDetails(daohuoZong, daohuoDetailsList);
//save時,儲存到貨單資料到申購執行,選擇其中daohuoDetailsList中shengoudanhao不為空的進行儲存轉換
int zhixingSaveCode = shengouZhixingService.saveDaohuoBindShengou(daohuoDetailsList, daohuoZong);
if (insertCode > 0 && zhixingSaveCode > 0) {
resultMap.put("success", true);
resultMap.put("msg", "儲存成功.");
// wuliaoKucunSearService.
return resultMap;
} else {
resultMap.put("success", false);
resultMap.put("errorInfo", "儲存失敗");
return resultMap;
}
}
/**
* 更新到貨總表
*
* @return
*/
@RequestMapping("/update")
public Map<String, Object> update(DaohuoZong daohuoZong) {
if (daohuoZong == null) {
return null;
}
Map<String, Object> resultMap = new HashMap<>();
int updateCode = daohuoZongService.updateByPrimaryKeySelective(daohuoZong);
if (updateCode > 0) {
resultMap.put("success", true);
return resultMap;
} else {
resultMap.put("success", false);
return resultMap;
}
}
/**
* 刪除 這裡的刪除同樣刪除了子表資料
*
* @param ids
* @return
*/
@RequestMapping("/delete")
@Transactional
public Map<String, Object> deleteBatch(@RequestParam("ids[]") Integer[] ids) throws Exception{
Map<String, Object> resultMap = new HashMap<>();
if (ids == null || ids.length == 0) {
resultMap.put("success", false);
resultMap.put("errorInfo", "請選中條目進行刪除");
return resultMap;
}
int ziDelCode = 0;
int delBindCode = shengouZhixingService.deleteDaohuoBindShengou(ids);//刪除申購執行中到貨資料的數值(update-少)
int delToKC = wuliaoKucunRiZhiService.insertButDeleteDaohuoShu(ids);
int code = daohuoZongService.deleteBatchByPKArr(ids); //批量刪除到貨主表
List<String> shengoudans = null;
if (code > 0) {
//刪除前先獲取他們的對應申購單s
shengoudans = daohuoDetailsService.listDuiyingShengouDan(ids);
//再刪除
ziDelCode = daohuoDetailsService.deleteByZongIdArr(ids); //批量刪除到貨詳細根據ids條目
}
if(ziDelCode>0){
// 再判定是否還有這些對應申購單
List<DaohuoDetails> daohuoDetails = daohuoDetailsService.listByDuiyingShengoudans(shengoudans);
if(CollectionUtils.isEmpty(daohuoDetails)){
for(String shengoudan:shengoudans){
int i = shengouZongService.updateCanDeleteToCan(shengoudan);
}
}
}
if (code > 0 && ziDelCode > 0 && delBindCode>0 && delToKC > 0) {
resultMap.put("success", true);
return resultMap;
} else {
resultMap.put("success", false);
return resultMap;
}
}
}