收盘:美股收高纳指再攀新高 特斯拉本周大涨近28%
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;
}
}
}
本文来自博客园,作者:ukyo--碳水化合物,转载请注明原文链接:https://www.cnblogs.com/ukzq/p/13288200.html

浙公网安备 33010602011771号