|
|
|
@ -15,16 +15,20 @@ import jnpf.model.yysmonthlyproduction.*;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import jnpf.annotation.JnpfField;
|
|
|
|
|
import jnpf.base.vo.PageListVO;
|
|
|
|
|
import jnpf.base.vo.PaginationVO;
|
|
|
|
|
import jnpf.base.vo.DownloadVO;
|
|
|
|
|
import jnpf.config.ConfigValueUtil;
|
|
|
|
|
import jnpf.base.entity.ProvinceEntity;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import jnpf.engine.entity.FlowTaskEntity;
|
|
|
|
|
import jnpf.exception.WorkFlowException;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
@ -36,7 +40,9 @@ import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
import jnpf.onlinedev.model.ExcelImFieldModel;
|
|
|
|
|
import jnpf.onlinedev.model.OnlineImport.ImportDataModel;
|
|
|
|
|
import jnpf.onlinedev.model.OnlineImport.ImportFormCheckUniqueModel;
|
|
|
|
@ -51,6 +57,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* yysMonthlyProduction
|
|
|
|
|
*
|
|
|
|
|
* @版本: V3.5
|
|
|
|
|
* @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
|
|
|
|
|
* @作者: JNPF开发平台组
|
|
|
|
@ -58,7 +65,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
|
@Tag(name = "yysMonthlyProduction" , description = "example")
|
|
|
|
|
@Tag(name = "yysMonthlyProduction", description = "example")
|
|
|
|
|
@RequestMapping("/api/example/YysMonthlyProduction")
|
|
|
|
|
public class YysMonthlyProductionController {
|
|
|
|
|
|
|
|
|
@ -72,30 +79,29 @@ public class YysMonthlyProductionController {
|
|
|
|
|
private YysMonthlyProductionService yysMonthlyProductionService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ConfigValueUtil configValueUtil;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表
|
|
|
|
|
*
|
|
|
|
|
* @param yysMonthlyProductionPagination
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 列表
|
|
|
|
|
*
|
|
|
|
|
* @param yysMonthlyProductionPagination
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "获取列表")
|
|
|
|
|
@PostMapping("/getList")
|
|
|
|
|
public ActionResult list(@RequestBody YysMonthlyProductionPagination yysMonthlyProductionPagination)throws IOException{
|
|
|
|
|
List<YysMonthlyProductionEntity> list= yysMonthlyProductionService.getList(yysMonthlyProductionPagination);
|
|
|
|
|
List<Map<String, Object>> realList=new ArrayList<>();
|
|
|
|
|
public ActionResult list(@RequestBody YysMonthlyProductionPagination yysMonthlyProductionPagination) throws IOException {
|
|
|
|
|
List<YysMonthlyProductionEntity> list = yysMonthlyProductionService.getList(yysMonthlyProductionPagination);
|
|
|
|
|
List<Map<String, Object>> realList = new ArrayList<>();
|
|
|
|
|
for (YysMonthlyProductionEntity entity : list) {
|
|
|
|
|
Map<String, Object> yysMonthlyProductionMap=JsonUtil.entityToMap(entity);
|
|
|
|
|
yysMonthlyProductionMap.put("id", yysMonthlyProductionMap.get("id"));
|
|
|
|
|
//副表数据
|
|
|
|
|
//子表数据
|
|
|
|
|
Map<String, Object> yysMonthlyProductionMap = JsonUtil.entityToMap(entity);
|
|
|
|
|
yysMonthlyProductionMap.put("id", yysMonthlyProductionMap.get("id"));
|
|
|
|
|
//副表数据
|
|
|
|
|
//子表数据
|
|
|
|
|
realList.add(yysMonthlyProductionMap);
|
|
|
|
|
}
|
|
|
|
|
//数据转换
|
|
|
|
|
realList = generaterSwapUtil.swapDataList(realList, YysMonthlyProductionConstant.getFormData(), YysMonthlyProductionConstant.getColumnData(), yysMonthlyProductionPagination.getModuleId(),false);
|
|
|
|
|
realList = generaterSwapUtil.swapDataList(realList, YysMonthlyProductionConstant.getFormData(), YysMonthlyProductionConstant.getColumnData(), yysMonthlyProductionPagination.getModuleId(), false);
|
|
|
|
|
|
|
|
|
|
//返回对象
|
|
|
|
|
PageListVO vo = new PageListVO();
|
|
|
|
@ -104,94 +110,100 @@ public class YysMonthlyProductionController {
|
|
|
|
|
vo.setPagination(page);
|
|
|
|
|
return ActionResult.success(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建
|
|
|
|
|
*
|
|
|
|
|
* @param yysMonthlyProductionForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 创建
|
|
|
|
|
*
|
|
|
|
|
* @param yysMonthlyProductionForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping()
|
|
|
|
|
@Operation(summary = "创建")
|
|
|
|
|
public ActionResult create(@RequestBody @Valid YysMonthlyProductionForm yysMonthlyProductionForm) {
|
|
|
|
|
String b = yysMonthlyProductionService.checkForm(yysMonthlyProductionForm,0);
|
|
|
|
|
if (StringUtil.isNotEmpty(b)){
|
|
|
|
|
return ActionResult.fail(b );
|
|
|
|
|
String b = yysMonthlyProductionService.checkForm(yysMonthlyProductionForm, 0);
|
|
|
|
|
if (StringUtil.isNotEmpty(b)) {
|
|
|
|
|
return ActionResult.fail(b);
|
|
|
|
|
}
|
|
|
|
|
String result = yysMonthlyProductionService.saveOrUpdate(yysMonthlyProductionForm, null, true);
|
|
|
|
|
if (result.contains("成功")) {
|
|
|
|
|
return ActionResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success(yysMonthlyProductionService.saveOrUpdate(yysMonthlyProductionForm, null, true));
|
|
|
|
|
return ActionResult.fail(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出Excel
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 导出Excel
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "导出Excel")
|
|
|
|
|
@PostMapping("/Actions/Export")
|
|
|
|
|
public ActionResult Export(@RequestBody YysMonthlyProductionPagination yysMonthlyProductionPagination) throws IOException {
|
|
|
|
|
if (StringUtil.isEmpty(yysMonthlyProductionPagination.getSelectKey())){
|
|
|
|
|
if (StringUtil.isEmpty(yysMonthlyProductionPagination.getSelectKey())) {
|
|
|
|
|
return ActionResult.fail("请选择导出字段");
|
|
|
|
|
}
|
|
|
|
|
List<YysMonthlyProductionEntity> list= yysMonthlyProductionService.getList(yysMonthlyProductionPagination);
|
|
|
|
|
List<Map<String, Object>> realList=new ArrayList<>();
|
|
|
|
|
List<YysMonthlyProductionEntity> list = yysMonthlyProductionService.getList(yysMonthlyProductionPagination);
|
|
|
|
|
List<Map<String, Object>> realList = new ArrayList<>();
|
|
|
|
|
for (YysMonthlyProductionEntity entity : list) {
|
|
|
|
|
Map<String, Object> yysMonthlyProductionMap=JsonUtil.entityToMap(entity);
|
|
|
|
|
yysMonthlyProductionMap.put("id", yysMonthlyProductionMap.get("id"));
|
|
|
|
|
//副表数据
|
|
|
|
|
//子表数据
|
|
|
|
|
Map<String, Object> yysMonthlyProductionMap = JsonUtil.entityToMap(entity);
|
|
|
|
|
yysMonthlyProductionMap.put("id", yysMonthlyProductionMap.get("id"));
|
|
|
|
|
//副表数据
|
|
|
|
|
//子表数据
|
|
|
|
|
realList.add(yysMonthlyProductionMap);
|
|
|
|
|
}
|
|
|
|
|
//数据转换
|
|
|
|
|
realList = generaterSwapUtil.swapDataList(realList, YysMonthlyProductionConstant.getFormData(), YysMonthlyProductionConstant.getColumnData(), yysMonthlyProductionPagination.getModuleId(),false);
|
|
|
|
|
String[]keys=!StringUtil.isEmpty(yysMonthlyProductionPagination.getSelectKey())?yysMonthlyProductionPagination.getSelectKey():new String[0];
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo);
|
|
|
|
|
realList = generaterSwapUtil.swapDataList(realList, YysMonthlyProductionConstant.getFormData(), YysMonthlyProductionConstant.getColumnData(), yysMonthlyProductionPagination.getModuleId(), false);
|
|
|
|
|
String[] keys = !StringUtil.isEmpty(yysMonthlyProductionPagination.getSelectKey()) ? yysMonthlyProductionPagination.getSelectKey() : new String[0];
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
DownloadVO vo = this.creatModelExcel(configValueUtil.getTemporaryFilePath(), realList, keys, userInfo);
|
|
|
|
|
return ActionResult.success(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出表格方法
|
|
|
|
|
*/
|
|
|
|
|
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo){
|
|
|
|
|
DownloadVO vo=DownloadVO.builder().build();
|
|
|
|
|
List<ExcelExportEntity> entitys=new ArrayList<>();
|
|
|
|
|
if(keys.length>0){
|
|
|
|
|
for(String key:keys){
|
|
|
|
|
switch(key){
|
|
|
|
|
case "years" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("年月" ,"years"));
|
|
|
|
|
break;
|
|
|
|
|
case "productId" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("产品编码" ,"productId"));
|
|
|
|
|
break;
|
|
|
|
|
case "productName" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("产品名称" ,"productName"));
|
|
|
|
|
break;
|
|
|
|
|
case "model" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("规格型号" ,"model"));
|
|
|
|
|
break;
|
|
|
|
|
case "measurementUnit" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("计量单位" ,"measurementUnit"));
|
|
|
|
|
break;
|
|
|
|
|
case "measurementNumber" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("计量数量" ,"measurementNumber"));
|
|
|
|
|
break;
|
|
|
|
|
case "currentInventory" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("当前库存" ,"currentInventory"));
|
|
|
|
|
break;
|
|
|
|
|
case "deliveryTime" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("交期" ,"deliveryTime"));
|
|
|
|
|
break;
|
|
|
|
|
* 导出表格方法
|
|
|
|
|
*/
|
|
|
|
|
public DownloadVO creatModelExcel(String path, List<Map<String, Object>> list, String[] keys, UserInfo userInfo) {
|
|
|
|
|
DownloadVO vo = DownloadVO.builder().build();
|
|
|
|
|
List<ExcelExportEntity> entitys = new ArrayList<>();
|
|
|
|
|
if (keys.length > 0) {
|
|
|
|
|
for (String key : keys) {
|
|
|
|
|
switch (key) {
|
|
|
|
|
case "years":
|
|
|
|
|
entitys.add(new ExcelExportEntity("年月", "years"));
|
|
|
|
|
break;
|
|
|
|
|
case "productId":
|
|
|
|
|
entitys.add(new ExcelExportEntity("产品编码", "productId"));
|
|
|
|
|
break;
|
|
|
|
|
case "productName":
|
|
|
|
|
entitys.add(new ExcelExportEntity("产品名称", "productName"));
|
|
|
|
|
break;
|
|
|
|
|
case "model":
|
|
|
|
|
entitys.add(new ExcelExportEntity("规格型号", "model"));
|
|
|
|
|
break;
|
|
|
|
|
case "measurementUnit":
|
|
|
|
|
entitys.add(new ExcelExportEntity("计量单位", "measurementUnit"));
|
|
|
|
|
break;
|
|
|
|
|
case "measurementNumber":
|
|
|
|
|
entitys.add(new ExcelExportEntity("计量数量", "measurementNumber"));
|
|
|
|
|
break;
|
|
|
|
|
case "currentInventory":
|
|
|
|
|
entitys.add(new ExcelExportEntity("当前库存", "currentInventory"));
|
|
|
|
|
break;
|
|
|
|
|
case "deliveryTime":
|
|
|
|
|
entitys.add(new ExcelExportEntity("交期", "deliveryTime"));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExportParams exportParams = new ExportParams(null, "表单信息");
|
|
|
|
|
exportParams.setType(ExcelType.XSSF);
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
@Cleanup Workbook workbook = new HSSFWorkbook();
|
|
|
|
|
if (entitys.size()>0){
|
|
|
|
|
if (list.size()==0){
|
|
|
|
|
if (entitys.size() > 0) {
|
|
|
|
|
if (list.size() == 0) {
|
|
|
|
|
list.add(new HashMap<>());
|
|
|
|
|
}
|
|
|
|
|
//去除空数据
|
|
|
|
@ -201,8 +213,8 @@ public class YysMonthlyProductionController {
|
|
|
|
|
for (String key : keys) {
|
|
|
|
|
//子表
|
|
|
|
|
if (key.toLowerCase().startsWith("tablefield")) {
|
|
|
|
|
String tableField = key.substring(0, key.indexOf("-" ));
|
|
|
|
|
String field = key.substring(key.indexOf("-" ) + 1);
|
|
|
|
|
String tableField = key.substring(0, key.indexOf("-"));
|
|
|
|
|
String field = key.substring(key.indexOf("-") + 1);
|
|
|
|
|
Object o = map.get(tableField);
|
|
|
|
|
if (o != null) {
|
|
|
|
|
List<Map<String, Object>> childList = (List<Map<String, Object>>) o;
|
|
|
|
@ -228,7 +240,7 @@ public class YysMonthlyProductionController {
|
|
|
|
|
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
|
|
|
|
|
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
|
|
|
|
|
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList);
|
|
|
|
|
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList);
|
|
|
|
|
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
|
|
|
|
@ -245,6 +257,7 @@ public class YysMonthlyProductionController {
|
|
|
|
|
}
|
|
|
|
|
return vo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "上传文件")
|
|
|
|
|
@PostMapping("/Uploader")
|
|
|
|
|
public ActionResult<Object> Uploader() {
|
|
|
|
@ -264,75 +277,75 @@ public class YysMonthlyProductionController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 模板下载
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 模板下载
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "模板下载")
|
|
|
|
|
@GetMapping("/TemplateDownload")
|
|
|
|
|
public ActionResult<DownloadVO> TemplateDownload(){
|
|
|
|
|
public ActionResult<DownloadVO> TemplateDownload() {
|
|
|
|
|
DownloadVO vo = DownloadVO.builder().build();
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
|
//主表对象
|
|
|
|
|
List<ExcelExportEntity> entitys = new ArrayList<>();
|
|
|
|
|
//以下添加字段
|
|
|
|
|
entitys.add(new ExcelExportEntity("年月" ,"years"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("产品编码" ,"productId"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("产品名称" ,"productName"));
|
|
|
|
|
dataMap.put("productName", "例:技术部/部门编码");
|
|
|
|
|
entitys.add(new ExcelExportEntity("规格型号" ,"model"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("计量单位" ,"measurementUnit"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("当前库存" ,"currentInventory"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("交期" ,"deliveryTime"));
|
|
|
|
|
dataMap.put("deliveryTime", "例: yyyy-MM-dd");
|
|
|
|
|
entitys.add(new ExcelExportEntity("计量数量" ,"measurementNumber"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("年月", "years"));
|
|
|
|
|
dataMap.put("years", "例: yyyy-MM");
|
|
|
|
|
entitys.add(new ExcelExportEntity("产品编码", "productId"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("产品名称", "productName"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("规格型号", "model"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("计量单位", "measurementUnit"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("当前库存", "currentInventory"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("交期", "deliveryTime"));
|
|
|
|
|
dataMap.put("deliveryTime", "例: yyyy-MM-dd");
|
|
|
|
|
entitys.add(new ExcelExportEntity("计量数量", "measurementNumber"));
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
list.add(dataMap);
|
|
|
|
|
|
|
|
|
|
ExportParams exportParams = new ExportParams(null, "月生产计划模板");
|
|
|
|
|
exportParams.setType(ExcelType.XSSF);
|
|
|
|
|
try{
|
|
|
|
|
@Cleanup Workbook workbook = new HSSFWorkbook();
|
|
|
|
|
if (entitys.size()>0){
|
|
|
|
|
if (list.size()==0){
|
|
|
|
|
list.add(new HashMap<>());
|
|
|
|
|
}
|
|
|
|
|
//复杂表头-表头和数据处理
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(YysMonthlyProductionConstant.getColumnData(), ColumnDataModel.class);
|
|
|
|
|
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
|
|
|
|
|
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
|
|
|
|
|
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList);
|
|
|
|
|
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList);
|
|
|
|
|
}
|
|
|
|
|
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
|
|
|
|
|
}
|
|
|
|
|
String fileName = "月生产计划模板" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xlsx";
|
|
|
|
|
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
|
|
|
|
|
try {
|
|
|
|
|
@Cleanup Workbook workbook = new HSSFWorkbook();
|
|
|
|
|
if (entitys.size() > 0) {
|
|
|
|
|
if (list.size() == 0) {
|
|
|
|
|
list.add(new HashMap<>());
|
|
|
|
|
}
|
|
|
|
|
//复杂表头-表头和数据处理
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(YysMonthlyProductionConstant.getColumnData(), ColumnDataModel.class);
|
|
|
|
|
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
|
|
|
|
|
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
|
|
|
|
|
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList);
|
|
|
|
|
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList);
|
|
|
|
|
}
|
|
|
|
|
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
|
|
|
|
|
}
|
|
|
|
|
String fileName = "月生产计划模板" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xlsx";
|
|
|
|
|
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
|
|
|
|
|
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
|
|
|
|
|
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
|
|
|
|
|
vo.setName(fileInfo.getFilename());
|
|
|
|
|
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
|
|
|
|
|
vo.setName(fileInfo.getFilename());
|
|
|
|
|
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("模板信息导出Excel错误:{}", e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("模板信息导出Excel错误:{}", e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入预览
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "导入预览" )
|
|
|
|
|
* 导入预览
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "导入预览")
|
|
|
|
|
@GetMapping("/ImportPreview")
|
|
|
|
|
public ActionResult<Map<String, Object>> ImportPreview(String fileName) throws Exception {
|
|
|
|
|
Map<String, Object> headAndDataMap = new HashMap<>(2);
|
|
|
|
|
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
|
|
|
|
|
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
|
|
|
|
|
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
|
|
|
|
|
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
|
|
|
|
|
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
|
|
|
|
|
int headerRowIndex = 1;
|
|
|
|
|
int headerRowIndex = 1;
|
|
|
|
|
ImportParams params = new ImportParams();
|
|
|
|
|
params.setTitleRows(0);
|
|
|
|
|
params.setHeadRows(headerRowIndex);
|
|
|
|
@ -341,17 +354,17 @@ public class YysMonthlyProductionController {
|
|
|
|
|
List<YysMonthlyProductionExcelVO> excelDataList = ExcelImportUtil.importExcel(temporary, YysMonthlyProductionExcelVO.class, params);
|
|
|
|
|
// 导入字段
|
|
|
|
|
List<ExcelImFieldModel> columns = new ArrayList<>();
|
|
|
|
|
columns.add(new ExcelImFieldModel("years","年月"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("productId","产品编码"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("productName","产品名称"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("model","规格型号"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("measurementUnit","计量单位"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("currentInventory","当前库存"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("deliveryTime","交期"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("measurementNumber","计量数量"));
|
|
|
|
|
headAndDataMap.put("dataRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(excelDataList)));
|
|
|
|
|
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
|
|
|
|
|
} catch (Exception e){
|
|
|
|
|
columns.add(new ExcelImFieldModel("years", "年月"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("productId", "产品编码"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("productName", "产品名称"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("model", "规格型号"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("measurementUnit", "计量单位"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("currentInventory", "当前库存"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("deliveryTime", "交期"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("measurementNumber", "计量数量"));
|
|
|
|
|
headAndDataMap.put("dataRow", JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(excelDataList)));
|
|
|
|
|
headAndDataMap.put("headerRow", JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return ActionResult.fail("表头名称不可更改,表头行不能删除");
|
|
|
|
|
}
|
|
|
|
@ -359,148 +372,156 @@ public class YysMonthlyProductionController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入数据
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "导入数据" )
|
|
|
|
|
* 导入数据
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "导入数据")
|
|
|
|
|
@PostMapping("/ImportData")
|
|
|
|
|
public ActionResult<ExcelImportModel> ImportData(@RequestBody VisualImportModel visualImportModel) throws Exception {
|
|
|
|
|
List<Map<String, Object>> listData=new ArrayList<>();
|
|
|
|
|
for(Map<String, Object> map : visualImportModel.getList()){
|
|
|
|
|
List<Map<String, Object>> listData = new ArrayList<>();
|
|
|
|
|
for (Map<String, Object> map : visualImportModel.getList()) {
|
|
|
|
|
listData.add(map);
|
|
|
|
|
}
|
|
|
|
|
ImportFormCheckUniqueModel uniqueModel = new ImportFormCheckUniqueModel();
|
|
|
|
|
uniqueModel.setDbLinkId(YysMonthlyProductionConstant.DBLINKID);
|
|
|
|
|
uniqueModel.setUpdate(Objects.equals("2", "2"));
|
|
|
|
|
ExcelImportModel excelImportModel = generaterSwapUtil.importData(YysMonthlyProductionConstant.getFormData(),listData,uniqueModel,
|
|
|
|
|
YysMonthlyProductionConstant.TABLEFIELDKEY,YysMonthlyProductionConstant.getTableList());
|
|
|
|
|
ExcelImportModel excelImportModel = generaterSwapUtil.importData(YysMonthlyProductionConstant.getFormData(), listData, uniqueModel,
|
|
|
|
|
YysMonthlyProductionConstant.TABLEFIELDKEY, YysMonthlyProductionConstant.getTableList());
|
|
|
|
|
List<ImportDataModel> importDataModel = uniqueModel.getImportDataModel();
|
|
|
|
|
for (ImportDataModel model : importDataModel) {
|
|
|
|
|
String id = model.getId();
|
|
|
|
|
Map<String, Object> result = model.getResultData();
|
|
|
|
|
if(StringUtil.isNotEmpty(id)){
|
|
|
|
|
update(id, JsonUtil.getJsonToBean(result,YysMonthlyProductionForm.class), true);
|
|
|
|
|
}else {
|
|
|
|
|
create( JsonUtil.getJsonToBean(result,YysMonthlyProductionForm.class));
|
|
|
|
|
if (StringUtil.isNotEmpty(id)) {
|
|
|
|
|
update(id, JsonUtil.getJsonToBean(result, YysMonthlyProductionForm.class), true);
|
|
|
|
|
} else {
|
|
|
|
|
create(JsonUtil.getJsonToBean(result, YysMonthlyProductionForm.class));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success(excelImportModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出异常报告
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 导出异常报告
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "导出异常报告")
|
|
|
|
|
@PostMapping("/ImportExceptionData")
|
|
|
|
|
public ActionResult<DownloadVO> ImportExceptionData(@RequestBody VisualImportModel visualImportModel) {
|
|
|
|
|
DownloadVO vo=DownloadVO.builder().build();
|
|
|
|
|
DownloadVO vo = DownloadVO.builder().build();
|
|
|
|
|
List<YysMonthlyProductionExcelErrorVO> yysMonthlyProductionVOList = JsonUtil.getJsonToList(visualImportModel.getList(), YysMonthlyProductionExcelErrorVO.class);
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
@Cleanup Workbook workbook = new HSSFWorkbook();
|
|
|
|
|
ExportParams exportParams = new ExportParams(null, "错误报告");
|
|
|
|
|
exportParams.setType(ExcelType.XSSF);
|
|
|
|
|
workbook = ExcelExportUtil.exportExcel(exportParams,
|
|
|
|
|
YysMonthlyProductionExcelErrorVO.class, yysMonthlyProductionVOList);
|
|
|
|
|
try {
|
|
|
|
|
@Cleanup Workbook workbook = new HSSFWorkbook();
|
|
|
|
|
ExportParams exportParams = new ExportParams(null, "错误报告");
|
|
|
|
|
exportParams.setType(ExcelType.XSSF);
|
|
|
|
|
workbook = ExcelExportUtil.exportExcel(exportParams,
|
|
|
|
|
YysMonthlyProductionExcelErrorVO.class, yysMonthlyProductionVOList);
|
|
|
|
|
|
|
|
|
|
String fileName = "错误报告" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".xlsx";
|
|
|
|
|
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
|
|
|
|
|
String fileName = "错误报告" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".xlsx";
|
|
|
|
|
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
|
|
|
|
|
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
|
|
|
|
|
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
|
|
|
|
|
vo.setName(fileInfo.getFilename());
|
|
|
|
|
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
|
|
|
|
|
vo.setName(fileInfo.getFilename());
|
|
|
|
|
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑
|
|
|
|
|
* @param id
|
|
|
|
|
* @param yysMonthlyProductionForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 编辑
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param yysMonthlyProductionForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping("/{id}")
|
|
|
|
|
@Operation(summary = "更新")
|
|
|
|
|
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid YysMonthlyProductionForm yysMonthlyProductionForm,
|
|
|
|
|
@RequestParam(value = "isImport", required = false) boolean isImport){
|
|
|
|
|
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid YysMonthlyProductionForm yysMonthlyProductionForm,
|
|
|
|
|
@RequestParam(value = "isImport", required = false) boolean isImport) {
|
|
|
|
|
yysMonthlyProductionForm.setId(id);
|
|
|
|
|
if (!isImport) {
|
|
|
|
|
String b = yysMonthlyProductionService.checkForm(yysMonthlyProductionForm,1);
|
|
|
|
|
if (StringUtil.isNotEmpty(b)){
|
|
|
|
|
return ActionResult.fail(b );
|
|
|
|
|
String b = yysMonthlyProductionService.checkForm(yysMonthlyProductionForm, 1);
|
|
|
|
|
if (StringUtil.isNotEmpty(b)) {
|
|
|
|
|
return ActionResult.fail(b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
YysMonthlyProductionEntity entity= yysMonthlyProductionService.getInfo(id);
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
try{
|
|
|
|
|
yysMonthlyProductionService.saveOrUpdate(yysMonthlyProductionForm,id,false);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
return ActionResult.fail("修改数据失败");
|
|
|
|
|
YysMonthlyProductionEntity entity = yysMonthlyProductionService.getInfo(id);
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
String result = yysMonthlyProductionService.saveOrUpdate(yysMonthlyProductionForm, null, false);
|
|
|
|
|
if (result.contains("成功")) {
|
|
|
|
|
return ActionResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success("更新成功");
|
|
|
|
|
}else{
|
|
|
|
|
return ActionResult.fail("更新失败,数据不存在");
|
|
|
|
|
return ActionResult.fail(result);
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.fail("操作失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 删除
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "删除")
|
|
|
|
|
@DeleteMapping("/{id}")
|
|
|
|
|
@Transactional
|
|
|
|
|
public ActionResult delete(@PathVariable("id") String id){
|
|
|
|
|
YysMonthlyProductionEntity entity= yysMonthlyProductionService.getInfo(id);
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
//主表数据删除
|
|
|
|
|
yysMonthlyProductionService.delete(entity);
|
|
|
|
|
public ActionResult delete(@PathVariable("id") String id) {
|
|
|
|
|
YysMonthlyProductionEntity entity = yysMonthlyProductionService.getInfo(id);
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
//假删除
|
|
|
|
|
entity.setDeleteMark(1);
|
|
|
|
|
entity.setDeleteTime(DateUtil.getNowDate());
|
|
|
|
|
yysMonthlyProductionService.update(id, entity);
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success("删除成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 表单信息(详情页)
|
|
|
|
|
* 详情页面使用-转换数据
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 表单信息(详情页)
|
|
|
|
|
* 详情页面使用-转换数据
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "表单信息(详情页)")
|
|
|
|
|
@GetMapping("/detail/{id}")
|
|
|
|
|
public ActionResult detailInfo(@PathVariable("id") String id){
|
|
|
|
|
YysMonthlyProductionEntity entity= yysMonthlyProductionService.getInfo(id);
|
|
|
|
|
if(entity==null){
|
|
|
|
|
public ActionResult detailInfo(@PathVariable("id") String id) {
|
|
|
|
|
YysMonthlyProductionEntity entity = yysMonthlyProductionService.getInfo(id);
|
|
|
|
|
if (entity == null) {
|
|
|
|
|
return ActionResult.fail("表单数据不存在!");
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> yysMonthlyProductionMap=JsonUtil.entityToMap(entity);
|
|
|
|
|
Map<String, Object> yysMonthlyProductionMap = JsonUtil.entityToMap(entity);
|
|
|
|
|
yysMonthlyProductionMap.put("id", yysMonthlyProductionMap.get("id"));
|
|
|
|
|
//副表数据
|
|
|
|
|
//子表数据
|
|
|
|
|
yysMonthlyProductionMap = generaterSwapUtil.swapDataDetail(yysMonthlyProductionMap,YysMonthlyProductionConstant.getFormData(),"590488386381285765",false);
|
|
|
|
|
yysMonthlyProductionMap = generaterSwapUtil.swapDataDetail(yysMonthlyProductionMap, YysMonthlyProductionConstant.getFormData(), "590488386381285765", false);
|
|
|
|
|
return ActionResult.success(yysMonthlyProductionMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取详情(编辑页)
|
|
|
|
|
* 编辑页面使用-不转换数据
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 获取详情(编辑页)
|
|
|
|
|
* 编辑页面使用-不转换数据
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "信息")
|
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
|
public ActionResult info(@PathVariable("id") String id){
|
|
|
|
|
YysMonthlyProductionEntity entity= yysMonthlyProductionService.getInfo(id);
|
|
|
|
|
if(entity==null){
|
|
|
|
|
public ActionResult info(@PathVariable("id") String id) {
|
|
|
|
|
YysMonthlyProductionEntity entity = yysMonthlyProductionService.getInfo(id);
|
|
|
|
|
if (entity == null) {
|
|
|
|
|
return ActionResult.fail("表单数据不存在!");
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> yysMonthlyProductionMap=JsonUtil.entityToMap(entity);
|
|
|
|
|
Map<String, Object> yysMonthlyProductionMap = JsonUtil.entityToMap(entity);
|
|
|
|
|
yysMonthlyProductionMap.put("id", yysMonthlyProductionMap.get("id"));
|
|
|
|
|
//副表数据
|
|
|
|
|
//子表数据
|
|
|
|
|
yysMonthlyProductionMap = generaterSwapUtil.swapDataForm(yysMonthlyProductionMap,YysMonthlyProductionConstant.getFormData(),YysMonthlyProductionConstant.TABLEFIELDKEY,YysMonthlyProductionConstant.TABLERENAMES);
|
|
|
|
|
yysMonthlyProductionMap = generaterSwapUtil.swapDataForm(yysMonthlyProductionMap, YysMonthlyProductionConstant.getFormData(), YysMonthlyProductionConstant.TABLEFIELDKEY, YysMonthlyProductionConstant.TABLERENAMES);
|
|
|
|
|
return ActionResult.success(yysMonthlyProductionMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|