工作中新模块相关类
This commit is contained in:
parent
bfd0281840
commit
df6f3d4ffe
|
|
@ -0,0 +1,60 @@
|
|||
package com.nflg.product.technology.api;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nflg.product.base.core.api.BaseApi;
|
||||
|
||||
import com.nflg.product.technology.pojo.query.ProcessWorkCenterQuery;
|
||||
import com.nflg.product.technology.pojo.vo.ProcessWorkCenterExcelVO;
|
||||
import com.nflg.product.technology.pojo.vo.ProcessWorkCenterVO;
|
||||
import com.nflg.product.technology.service.ProcessWorkCenterService;
|
||||
import com.nflg.product.technology.util.EecExcelUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工艺管理-工作中心表控制层
|
||||
*
|
||||
* @author makejava
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("processWorkCenter")
|
||||
public class ProcessWorkCenterApi extends BaseApi {
|
||||
|
||||
@Resource
|
||||
private ProcessWorkCenterService processWorkCenterService;
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
*
|
||||
* @param query Query 查询实体
|
||||
* @return 所有数据
|
||||
*/
|
||||
@PostMapping("page")
|
||||
public ResultVO<IPage<ProcessWorkCenterVO>> selectAll(@RequestBody ProcessWorkCenterQuery query) {
|
||||
return ResultVO.success(processWorkCenterService.selectPageByCondition(query));
|
||||
}
|
||||
|
||||
@PostMapping("export")
|
||||
@ApiOperation("导出")
|
||||
public void export(@RequestBody ProcessWorkCenterQuery query, HttpServletResponse response) throws IOException {
|
||||
List<ProcessWorkCenterVO> data = processWorkCenterService.selectPageByCondition(query).getRecords();
|
||||
EecExcelUtil.export(response, Convert.toList(ProcessWorkCenterExcelVO.class, data), ProcessWorkCenterExcelVO.class, "工作中心");
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步SAP的工作中心数据
|
||||
*
|
||||
*/
|
||||
@GetMapping("fromSap")
|
||||
public ResultVO<Boolean> fromSap() {
|
||||
return processWorkCenterService.fromSap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.nflg.product.technology.job;
|
||||
|
||||
//import com.nflg.product.bomnew.service.ProcessWorkCenterService;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @decription 工作中心定时任务
|
||||
* @Author ljd
|
||||
* @Date 2024/11/14
|
||||
**/
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class ProcessWorkCenterTask {
|
||||
/* @Resource
|
||||
private ProcessWorkCenterService;
|
||||
|
||||
|
||||
*//**
|
||||
*
|
||||
*
|
||||
*//*
|
||||
// @Scheduled(cron = "0 0/10 * * * ?")
|
||||
public void plmConvertBom() throws Exception {
|
||||
processWorkCenterService.fromSap();
|
||||
}*/
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.nflg.product.technology.mapper.master;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.product.technology.pojo.entity.ProcessWorkCenterEntity;
|
||||
import com.nflg.product.technology.pojo.query.ProcessWorkCenterQuery;
|
||||
import com.nflg.product.technology.pojo.vo.ProcessWorkCenterVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工艺管理-工作中心表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
*/
|
||||
public interface ProcessWorkCenterMapper extends BaseMapper<ProcessWorkCenterEntity> {
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<ProcessWorkCenterEntity> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<ProcessWorkCenterEntity> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<ProcessWorkCenterEntity> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<ProcessWorkCenterEntity> entities);
|
||||
|
||||
IPage<ProcessWorkCenterVO> selectPageByCondition(Page<ProcessWorkCenterEntity> page, @Param("query") ProcessWorkCenterQuery query);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
package com.nflg.product.technology.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 工艺管理-工作中心表实体类
|
||||
*
|
||||
* @author makejava
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "t_process_workcenter")
|
||||
public class ProcessWorkCenterEntity implements Serializable {
|
||||
|
||||
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
|
||||
private Long rowId;
|
||||
|
||||
//工厂
|
||||
@TableField(value = "factory")
|
||||
private String factory;
|
||||
|
||||
//工作中心
|
||||
@TableField(value = "work_center")
|
||||
private String workCenter;
|
||||
|
||||
//名称
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
//工作中心类别
|
||||
@TableField(value = "type")
|
||||
private String type;
|
||||
|
||||
//描述
|
||||
@TableField(value = "description")
|
||||
private String description;
|
||||
|
||||
//负责人
|
||||
@TableField(value = "header")
|
||||
private String header;
|
||||
|
||||
//负责人描述
|
||||
@TableField(value = "header_description")
|
||||
private String headerDescription;
|
||||
|
||||
//用途
|
||||
@TableField(value = "usefulness")
|
||||
private String usefulness;
|
||||
|
||||
//用途描述
|
||||
@TableField(value = "usefulness_description")
|
||||
private String usefulnessDescription;
|
||||
|
||||
//是否反冲:false = 否、true = 是
|
||||
@TableField(value = "recoil")
|
||||
private Boolean recoil;
|
||||
|
||||
//标准值码
|
||||
@TableField(value = "standard_code")
|
||||
private String standardCode;
|
||||
|
||||
//标准值码描述
|
||||
@TableField(value = "standard_code_description")
|
||||
private String standardCodeDescription;
|
||||
|
||||
//标准文本码
|
||||
@TableField(value = "standard_text_code")
|
||||
private String standardTextCode;
|
||||
|
||||
//标准文本码描述
|
||||
@TableField(value = "standard_text_code_description")
|
||||
private String standardTextCodeDescription;
|
||||
|
||||
//加工公式
|
||||
@TableField(value = "processing_formula")
|
||||
private String processingFormula;
|
||||
|
||||
//加工公式描述
|
||||
@TableField(value = "processing_formula_description")
|
||||
private String processingFormulaDescription;
|
||||
|
||||
//成本控制范围
|
||||
@TableField(value = "cost_controlling_area")
|
||||
private String costControllingArea;
|
||||
|
||||
//成本中心
|
||||
@TableField(value = "cost_center")
|
||||
private String costCenter;
|
||||
|
||||
//成本中心描述
|
||||
@TableField(value = "cost_center_description")
|
||||
private String costCenterDescription;
|
||||
|
||||
//开始日期
|
||||
@TableField(value = "start_time")
|
||||
private Date startTime;
|
||||
|
||||
//结束日期
|
||||
@TableField(value = "end_time")
|
||||
private Date endTime;
|
||||
|
||||
@TableField(value = "created_by")
|
||||
private String createdBy;
|
||||
|
||||
@TableField(value = "created_time")
|
||||
private Date createdTime;
|
||||
|
||||
@TableField(value = "updated_by")
|
||||
private String updatedBy;
|
||||
|
||||
@TableField(value = "updated_time")
|
||||
private Date updatedTime;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.nflg.product.technology.pojo.query;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 大米
|
||||
* @date 2023/11/9 10:12
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BasePageQuery {
|
||||
@ApiModelProperty(value = "设置每页显示条数")
|
||||
private Long pageSize = 20L;
|
||||
|
||||
@ApiModelProperty(value = "当前页")
|
||||
private Long page = 1L;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.nflg.product.technology.pojo.query;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProcessWorkCenterQuery {
|
||||
|
||||
// 工厂
|
||||
private String factory;
|
||||
|
||||
//工作中心
|
||||
private String workCenters;
|
||||
|
||||
//工作中心
|
||||
private List<String> workCenterList;
|
||||
|
||||
private List<Long> rowIdList;
|
||||
|
||||
@ApiModelProperty(value = "设置每页显示条数")
|
||||
private Long pageSize = 20L;
|
||||
|
||||
@ApiModelProperty(value = "当前页")
|
||||
private Long page = 1L;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.product.technology.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @decription
|
||||
* @Author 大米
|
||||
* @Date 2022/8/9 15:43
|
||||
**/
|
||||
@Data
|
||||
public class BaseImportExcelDTO {
|
||||
|
||||
@ApiModelProperty("行号")
|
||||
private int rowNum;
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
package com.nflg.product.technology.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 工艺管理-工作中心
|
||||
*
|
||||
* @author makejava
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProcessWorkCenterExcelVO extends BaseImportExcelDTO {
|
||||
|
||||
// private Long rowId;
|
||||
|
||||
//工厂
|
||||
@ExcelColumn("工厂")
|
||||
private String factory;
|
||||
|
||||
//工作中心
|
||||
@ExcelColumn("工作中心")
|
||||
private String workCenter;
|
||||
|
||||
//名称
|
||||
@ExcelColumn("名称")
|
||||
private String name;
|
||||
|
||||
//工作中心类别
|
||||
@ExcelColumn("工作中心类别")
|
||||
private String type;
|
||||
|
||||
//描述
|
||||
@ExcelColumn("描述")
|
||||
private String description;
|
||||
|
||||
//负责人
|
||||
@ExcelColumn("负责人")
|
||||
private String header;
|
||||
|
||||
//负责人描述
|
||||
@ExcelColumn("负责人描述")
|
||||
private String headerDescription;
|
||||
|
||||
//用途
|
||||
@ExcelColumn("用途")
|
||||
private String usefulness;
|
||||
|
||||
//用途描述
|
||||
@ExcelColumn("用途描述")
|
||||
private String usefulnessDescription;
|
||||
|
||||
//是否反冲:false = 否、true = 是
|
||||
@ExcelColumn("是否反冲")
|
||||
private Boolean recoil;
|
||||
|
||||
//标准值码
|
||||
@ExcelColumn("标准值码")
|
||||
private String standardCode;
|
||||
|
||||
//标准值码描述
|
||||
@ExcelColumn("标准值码描述")
|
||||
private String standardCodeDescription;
|
||||
|
||||
//标准文本码
|
||||
@ExcelColumn("标准文本码")
|
||||
private String standardTextCode;
|
||||
|
||||
//标准文本码描述
|
||||
@ExcelColumn("标准文本码描述")
|
||||
private String standardTextCodeDescription;
|
||||
|
||||
//加工公式
|
||||
@ExcelColumn("加工公式")
|
||||
private String processingFormula;
|
||||
|
||||
//加工公式描述
|
||||
@ExcelColumn("加工公式描述")
|
||||
private String processingFormulaDescription;
|
||||
|
||||
//成本控制范围
|
||||
@ExcelColumn("成本控制范围")
|
||||
private String costControllingArea;
|
||||
|
||||
//成本中心
|
||||
@ExcelColumn("成本中心")
|
||||
private String costCenter;
|
||||
|
||||
//成本中心描述
|
||||
@ExcelColumn("成本中心描述")
|
||||
private String costCenterDescription;
|
||||
|
||||
//开始日期
|
||||
@ExcelColumn("开始日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-8")
|
||||
private Date startTime;
|
||||
|
||||
//结束日期
|
||||
@ExcelColumn("结束日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-8")
|
||||
private Date endTime;
|
||||
|
||||
//创建人
|
||||
@ExcelColumn("创建人")
|
||||
private String createBy;
|
||||
|
||||
//创建时间
|
||||
@ExcelColumn("创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-8")
|
||||
private Date createTime;
|
||||
|
||||
//更新人
|
||||
@ExcelColumn("更新人")
|
||||
private String updateBy;
|
||||
|
||||
//更新时间
|
||||
@ExcelColumn("更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-8")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.nflg.product.technology.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 工艺管理-工作中心
|
||||
*
|
||||
* @author makejava
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProcessWorkCenterVO implements Serializable {
|
||||
|
||||
private Long rowId;
|
||||
|
||||
//工厂
|
||||
private String factory;
|
||||
|
||||
//工作中心
|
||||
private String workCenter;
|
||||
|
||||
//名称
|
||||
private String name;
|
||||
|
||||
//工作中心类别
|
||||
private String type;
|
||||
|
||||
//描述
|
||||
private String description;
|
||||
|
||||
//负责人
|
||||
private String header;
|
||||
|
||||
//负责人描述
|
||||
private String headerDescription;
|
||||
|
||||
//用途
|
||||
private String usefulness;
|
||||
|
||||
//用途描述
|
||||
private String usefulnessDescription;
|
||||
|
||||
//是否反冲:false = 否、true = 是
|
||||
private Boolean recoil;
|
||||
|
||||
//标准值码
|
||||
private String standardCode;
|
||||
|
||||
//标准值码描述
|
||||
private String standardCodeDescription;
|
||||
|
||||
//标准文本码
|
||||
private String standardTextCode;
|
||||
|
||||
//标准文本码描述
|
||||
private String standardTextCodeDescription;
|
||||
|
||||
//加工公式
|
||||
private String processingFormula;
|
||||
|
||||
//加工公式描述
|
||||
private String processingFormulaDescription;
|
||||
|
||||
//成本控制范围
|
||||
private String costControllingArea;
|
||||
|
||||
//成本中心
|
||||
private String costCenter;
|
||||
|
||||
//成本中心描述
|
||||
private String costCenterDescription;
|
||||
|
||||
//开始日期
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-8")
|
||||
private Date startTime;
|
||||
|
||||
//结束日期
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-8")
|
||||
private Date endTime;
|
||||
|
||||
//创建人
|
||||
private String createBy;
|
||||
|
||||
//创建时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-8")
|
||||
private Date createTime;
|
||||
|
||||
//更新人
|
||||
private String updateBy;
|
||||
|
||||
//更新时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-8")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
package com.nflg.product.technology.service;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.base.core.vo.PageVO;
|
||||
import com.nflg.product.technology.mapper.master.ProcessWorkCenterMapper;
|
||||
import com.nflg.product.technology.pojo.dto.sap.SapReqParams;
|
||||
import com.nflg.product.technology.pojo.dto.sap.SapResult;
|
||||
import com.nflg.product.technology.pojo.entity.ProcessWorkCenterEntity;
|
||||
import com.nflg.product.technology.pojo.query.ProcessWorkCenterQuery;
|
||||
import com.nflg.product.technology.pojo.vo.ProcessWorkCenterVO;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 工艺管理-工作中心(BomTechnologyWorkCenter)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
*/
|
||||
@Service
|
||||
public class ProcessWorkCenterService extends ServiceImpl<ProcessWorkCenterMapper, ProcessWorkCenterEntity> {
|
||||
|
||||
@Resource
|
||||
private ProcessWorkCenterMapper processWorkCenterMapper;
|
||||
|
||||
@Resource
|
||||
SapService sapService;
|
||||
|
||||
public IPage<ProcessWorkCenterVO> selectPageByCondition(ProcessWorkCenterQuery query) {
|
||||
if (StringUtils.isNotEmpty(query.getWorkCenters())) {
|
||||
List<String> workCenterList = Arrays.asList(query.getWorkCenters().split(","));
|
||||
query.setWorkCenterList(workCenterList);
|
||||
}
|
||||
|
||||
//设置分页
|
||||
Page<ProcessWorkCenterEntity> pageCondition = new PageVO<>(query.getPage(), query.getPageSize());
|
||||
return processWorkCenterMapper.selectPageByCondition(pageCondition, query);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Boolean> fromSap() {
|
||||
//List<ProcessWorkCenterVO> list = new ArrayList<>();
|
||||
SapReqParams params = new SapReqParams();
|
||||
// 接口名
|
||||
params.setFunName("ZRFC_MM_GETDATA");
|
||||
Map<String, Object> inputParams = new HashMap<>(1);
|
||||
inputParams.put("I_ZBZXFLG", "X");
|
||||
params.setInputParams(inputParams);
|
||||
try {
|
||||
SapResult sapResult = sapService.doSapFun(params);
|
||||
Map<String, List<Map<String, Object>>> outTablesMap = sapResult.getOutTablesMap();
|
||||
List<Map<String, Object>> tOut = outTablesMap.get("T_CBZX");
|
||||
if (!sapResult.isSuccess()) {
|
||||
throw new NflgBusinessException(STATE.Error, "接口连接失败");
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(tOut)) {
|
||||
|
||||
List<ProcessWorkCenterEntity> addList = new ArrayList<>(tOut.size());
|
||||
tOut.forEach(out -> {
|
||||
ProcessWorkCenterEntity add = new ProcessWorkCenterEntity();
|
||||
add.setRowId(IdWorker.getId());
|
||||
// add.setMaterialNo(out.get("MATNR").toString().replaceAll("^[0]+",""));
|
||||
add.setWorkCenter(out.get("ARBPL").toString());
|
||||
add.setFactory(out.get("WERKS").toString());
|
||||
add.setName(out.get("KTEXT1").toString());
|
||||
add.setType(out.get("VERWE").toString());
|
||||
// workCenter.setDescription();// 描述
|
||||
add.setHeader(out.get("VERAN").toString());
|
||||
add.setHeaderDescription(out.get("KTEXT").toString());
|
||||
add.setUsefulness(out.get("PLANV").toString());
|
||||
add.setUsefulnessDescription(out.get("TXT").toString());
|
||||
String recoil=out.get("RGEKZ").toString();
|
||||
if(StringUtils.isNotBlank(recoil)&&recoil.equals("X")){// 是否反冲SAP的值是:""和X,分别代表
|
||||
add.setRecoil(false);
|
||||
}else{
|
||||
add.setRecoil(true);
|
||||
}
|
||||
add.setStandardCode(out.get("VGWTS").toString());
|
||||
add.setStandardCodeDescription(out.get("TXT1").toString());
|
||||
add.setStandardTextCode(out.get("KTSCH").toString());
|
||||
add.setStandardTextCodeDescription(out.get("KTEXT2").toString());
|
||||
add.setProcessingFormula(out.get("IDENT").toString());
|
||||
add.setProcessingFormulaDescription(out.get("TXT2").toString());
|
||||
add.setCostControllingArea(out.get("KOKRS").toString());
|
||||
add.setCostCenter(out.get("KOSTL").toString());
|
||||
add.setCreatedBy(SessionUtil.getUserName());
|
||||
add.setCreatedTime(new Date());
|
||||
add.setUpdatedBy(SessionUtil.getUserName());
|
||||
add.setUpdatedTime(new Date());
|
||||
// workCenter.setCostCenterDescription();// 成本中心描述
|
||||
// workCenter.setStartTime();//开始日期
|
||||
// workCenter.setEndTime();结束日期
|
||||
// processWorkCenterMapper.insert(add);
|
||||
addList.add(add);
|
||||
});
|
||||
// 删除旧数据
|
||||
LambdaQueryWrapper<ProcessWorkCenterEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
processWorkCenterMapper.delete(wrapper);
|
||||
|
||||
//全量新增
|
||||
processWorkCenterMapper.insertBatch(addList);
|
||||
/* list = Convert.convert(new TypeReference<List<ProcessWorkCenterVO>>() {
|
||||
}, tOut);*/
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
package com.nflg.product.technology.util;
|
||||
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.ttzero.excel.entity.ListSheet;
|
||||
import org.ttzero.excel.entity.Workbook;
|
||||
import org.ttzero.excel.reader.ExcelReader;
|
||||
import org.ttzero.excel.reader.Row;
|
||||
import org.ttzero.excel.reader.Sheet;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* eecExcel
|
||||
*
|
||||
* @Author 大米
|
||||
* @Date 2022-03-23
|
||||
*/
|
||||
public class EecExcelUtil {
|
||||
|
||||
/**
|
||||
* 下载本地文件
|
||||
*
|
||||
* @param filePath 文件地址
|
||||
* @param response 输出流
|
||||
* @param fileName 文件名
|
||||
* @param format
|
||||
*/
|
||||
public static void downLocalFile(String filePath, HttpServletResponse response, String fileName, String format) throws IOException {
|
||||
response.setHeader("content-Type", "application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
System.out.println("开始下载文件");
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
ServletOutputStream ouputStream = response.getOutputStream();
|
||||
byte b[] = new byte[1024];
|
||||
int n;
|
||||
while ((n = inputStream.read(b)) != -1) {
|
||||
ouputStream.write(b, 0, n);
|
||||
}
|
||||
ouputStream.close();
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void setResponseExcelHeader(HttpServletResponse response, String fileName) throws UnsupportedEncodingException {
|
||||
response.setHeader("content-Type", "application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "utf-8"));
|
||||
|
||||
}
|
||||
|
||||
public static void eecExcel(String fileName, ListSheet sheet, HttpServletResponse response) throws IOException {
|
||||
setResponseExcelHeader(response, fileName);
|
||||
new Workbook().addSheet(sheet
|
||||
).writeTo(response.getOutputStream());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void eecExcel(String fileName, ListSheet sheet, OutputStream outputStream) throws IOException {
|
||||
//setResponseExcelHeader(response, fileName);
|
||||
new Workbook().addSheet(sheet
|
||||
).writeTo(outputStream);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 行读取excel sheet 0
|
||||
*
|
||||
* @param hanlder
|
||||
* @param inputStream
|
||||
*/
|
||||
public static <T, U> void iteratorRead(BiConsumer<T, U> hanlder, InputStream inputStream, Class<T> cls, U u) {
|
||||
try (ExcelReader reader = ExcelReader.read(inputStream)) {
|
||||
Sheet sheet = reader.sheet(0);
|
||||
Iterator<Row> ite = sheet.iterator();
|
||||
while (ite.hasNext()) {
|
||||
hanlder.accept(ite.next().to(cls), u);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new NflgBusinessException(STATE.BusinessError, "读取EXCEL 失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取EXCEL 所有内容
|
||||
*
|
||||
* @param inputStream
|
||||
* @param clc
|
||||
* @param <T>
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static <T> List<T> getExcelContext(InputStream inputStream, Class<T> clc) throws IOException {
|
||||
try {
|
||||
return ExcelReader.read(inputStream)
|
||||
.sheet(0)
|
||||
.dataRows() // 所有数据列,会过滤掉表头
|
||||
.map(row -> row.to(clc))// 列数据转Stock对象
|
||||
.collect(Collectors.toList());// 转为对象数组
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new NflgBusinessException(STATE.BusinessError, "读取EXCEL 失败,请检查模板是否正确:" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 每行excel 做处理
|
||||
*
|
||||
* @param inputStream
|
||||
* @param clc
|
||||
* @param handler
|
||||
* @param <T>
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static <T extends BaseImportExcelDTO> List<T> handlerExcel(InputStream inputStream, Class<T> clc, Consumer<T> handler) {
|
||||
|
||||
try (ExcelReader reader = ExcelReader.read(inputStream)) {
|
||||
|
||||
reader.sheet(0).dataRows().map(row-> row.to(clc)
|
||||
// T t= row.too(clc);
|
||||
// t.setRowNum(row.getRowNum());
|
||||
// return t ;
|
||||
).forEach(u -> {
|
||||
if(handler!=null) {
|
||||
handler.accept(u);
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
throw new NflgBusinessException(STATE.ParamErr, "excel 解析失败,请检查模板是否正确");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取sheet名称
|
||||
* @param inputStream
|
||||
* @return
|
||||
*/
|
||||
public static String getSheetName(InputStream inputStream){
|
||||
try (ExcelReader reader = ExcelReader.read(inputStream)) {
|
||||
return reader.sheet(0).getName();
|
||||
} catch (IOException e) {
|
||||
throw new NflgBusinessException(STATE.ParamErr, "excel 解析失败,请检查模板是否正确");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除excel单元格中的空格,excel导入时的字符串空格ASCII值为160,而空格(space)的ASCII值是32
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String StringTrim(String str) {
|
||||
return str.replaceAll("[\\s\\u00A0]+", "").trim();
|
||||
}
|
||||
|
||||
public static <T> void export(HttpServletResponse response, List<T> data,Class<?> clazz,String name) throws IOException {
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(name, "utf-8") + ".xlsx\"");
|
||||
new Workbook().addSheet(new ListSheet<T>() {
|
||||
@Override
|
||||
protected Class<?> getTClass() {
|
||||
return clazz; // 指定类型
|
||||
}
|
||||
}.setData(data)).writeTo(response.getOutputStream());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.product.technology.mapper.master.ProcessWorkCenterMapper">
|
||||
|
||||
<resultMap type="com.nflg.product.bomnew.pojo.entity.ProcessWorkCenterEntity" id="ProcessWorkCenterMap">
|
||||
<result property="rowId" column="row_id" jdbcType="INTEGER"/>
|
||||
<result property="factory" column="factory" jdbcType="VARCHAR"/>
|
||||
<result property="workCenter" column="work_center" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="type" column="type" jdbcType="VARCHAR"/>
|
||||
<result property="description" column="description" jdbcType="VARCHAR"/>
|
||||
<result property="header" column="header" jdbcType="VARCHAR"/>
|
||||
<result property="headerDescription" column="header_description" jdbcType="VARCHAR"/>
|
||||
<result property="usefulness" column="usefulness" jdbcType="VARCHAR"/>
|
||||
<result property="usefulnessDescription" column="usefulness_description" jdbcType="VARCHAR"/>
|
||||
<result property="recoil" column="recoil" jdbcType="INTEGER"/>
|
||||
<result property="standardCode" column="standard_code" jdbcType="VARCHAR"/>
|
||||
<result property="standardCodeDescription" column="standard_code_description" jdbcType="VARCHAR"/>
|
||||
<result property="standardTextCode" column="standard_text_code" jdbcType="VARCHAR"/>
|
||||
<result property="standardTextCodeDescription" column="standard_text_code_description" jdbcType="VARCHAR"/>
|
||||
<result property="processingFormula" column="processing_formula" jdbcType="VARCHAR"/>
|
||||
<result property="processingFormulaDescription" column="processing_formula_description" jdbcType="VARCHAR"/>
|
||||
<result property="costControllingArea" column="cost_controlling_area" jdbcType="VARCHAR"/>
|
||||
<result property="costCenter" column="cost_center" jdbcType="VARCHAR"/>
|
||||
<result property="costCenterDescription" column="cost_center_description" jdbcType="VARCHAR"/>
|
||||
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedBy" column="updated_by" jdbcType="VARCHAR"/>
|
||||
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 批量插入 -->
|
||||
<insert id="insertBatch" ><!--keyProperty="rowId" useGeneratedKeys="true"-->
|
||||
insert into t_process_workcenter(row_id,factory,work_center, `name`, type, `description`, header,
|
||||
header_description, usefulness, usefulness_description, recoil, standard_code, standard_code_description,
|
||||
standard_text_code, standard_text_code_description, processing_formula, processing_formula_description,
|
||||
cost_controlling_area, cost_center, cost_center_description, start_time, end_time, created_by, created_time,
|
||||
updated_by, updated_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.rowId},#{entity.factory}, #{entity.workCenter}, #{entity.name}, #{entity.type}, #{entity.description}, #{entity.header},
|
||||
#{entity.headerDescription}, #{entity.usefulness}, #{entity.usefulnessDescription}, #{entity.recoil},
|
||||
#{entity.standardCode}, #{entity.standardCodeDescription}, #{entity.standardTextCode},
|
||||
#{entity.standardTextCodeDescription}, #{entity.processingFormula}, #{entity.processingFormulaDescription},
|
||||
#{entity.costControllingArea}, #{entity.costCenter}, #{entity.costCenterDescription}, #{entity.startTime},
|
||||
#{entity.endTime}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy}, #{entity.updatedTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
<!-- 批量插入或按主键更新 -->
|
||||
<insert id="insertOrUpdateBatch" keyProperty="rowId" useGeneratedKeys="true">
|
||||
insert into t_process_workcenter(factory,work_center, `name`, type, `description`, header,
|
||||
header_description, usefulness, usefulness_description, recoil, standard_code, standard_code_description,
|
||||
standard_text_code, standard_text_code_description, processing_formula, processing_formula_description,
|
||||
cost_controlling_area, cost_center, cost_center_description, start_time, end_time, created_by, created_time,
|
||||
updated_by, updated_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.factory}, (#{entity.workCenter}, #{entity.name}, #{entity.type}, #{entity.description}, #{entity.header},
|
||||
#{entity.headerDescription}, #{entity.usefulness}, #{entity.usefulnessDescription}, #{entity.recoil},
|
||||
#{entity.standardCode}, #{entity.standardCodeDescription}, #{entity.standardTextCode},
|
||||
#{entity.standardTextCodeDescription}, #{entity.processingFormula}, #{entity.processingFormulaDescription},
|
||||
#{entity.costControllingArea}, #{entity.costCenter}, #{entity.costCenterDescription}, #{entity.startTime},
|
||||
#{entity.endTime}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy}, #{entity.updatedTime})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
factory = values(factory) , work_center = values(work_center) , name = values(name) , type = values(type) , description =
|
||||
values(description) , header = values(header) , header_description = values(header_description) , usefulness =
|
||||
values(usefulness) , usefulness_description = values(usefulness_description) , recoil = values(recoil) ,
|
||||
standard_code = values(standard_code) , standard_code_description = values(standard_code_description) ,
|
||||
standard_text_code = values(standard_text_code) , standard_text_code_description =
|
||||
values(standard_text_code_description) , processing_formula = values(processing_formula) ,
|
||||
processing_formula_description = values(processing_formula_description) , cost_controlling_area =
|
||||
values(cost_controlling_area) , cost_center = values(cost_center) , cost_center_description =
|
||||
values(cost_center_description) , start_time = values(start_time) , end_time = values(end_time) , created_by =
|
||||
values(created_by) , created_time = values(created_time) , updated_by = values(updated_by) , updated_time =
|
||||
values(updated_time)
|
||||
</insert>
|
||||
|
||||
<sql id="base_column_list">
|
||||
row_id, factory,work_center, `name`, type, `description`, header,
|
||||
header_description, usefulness, usefulness_description, recoil, standard_code, standard_code_description,
|
||||
standard_text_code, standard_text_code_description, processing_formula, processing_formula_description,
|
||||
cost_controlling_area, cost_center, cost_center_description, start_time, end_time
|
||||
</sql>
|
||||
|
||||
<sql id="where_whr">
|
||||
<where>
|
||||
<if test="query.factory != null and query.factory != ''">
|
||||
AND factory = #{query.factory}
|
||||
</if>
|
||||
<if test="query.workCenterList != null and query.workCenterList.size > 0">
|
||||
AND work_center IN
|
||||
<foreach collection="query.workCenterList" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="query.rowIdList != null and query.rowIdList.size > 0">
|
||||
AND row_id IN
|
||||
<foreach collection="query.rowIdList" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="selectPageByCondition" resultType="com.nflg.product.bomnew.pojo.vo.ProcessWorkCenterVO">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from t_process_workcenter
|
||||
<include refid="where_whr"/>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue