|
|
@ -1,11 +1,27 @@
|
|
|
|
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
|
|
|
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.excel.MesExcelTool;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentProdParamCfg;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesTimeEfficientCfg;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesTimeEfficientCfg;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.RedisCacheTool;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 时效性维护
|
|
|
|
* 时效性维护
|
|
|
@ -16,5 +32,37 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
public class MesTimeEfficientCfgController extends BaseMesController<MesTimeEfficientCfg>{
|
|
|
|
public class MesTimeEfficientCfgController extends BaseMesController<MesTimeEfficientCfg>{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/import-data")
|
|
|
|
|
|
|
|
@ApiOperation(value = "导入数据")
|
|
|
|
|
|
|
|
public ResultBean importNew(@RequestParam("file") MultipartFile file, @RequestParam("sourceId")Long sourceId) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MesExcelTool excelTool = new MesExcelTool(entityManager, RedisCacheTool.getImppRedis());
|
|
|
|
|
|
|
|
List<MesTimeEfficientCfg> beanList = excelTool.importData(file.getOriginalFilename(), file.getInputStream(), mesClass);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验导入数据
|
|
|
|
|
|
|
|
baseService.validateImport(beanList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
beanList.forEach(mesEquipmentProdParamCfg -> {
|
|
|
|
|
|
|
|
mesEquipmentProdParamCfg.setSourceId(sourceId);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String userName = AuthUtil.getSessionUser().getUserName();
|
|
|
|
|
|
|
|
String organizeCode = AuthUtil.getOrganize().getOrganizeCode();
|
|
|
|
|
|
|
|
// 导入数据初始化
|
|
|
|
|
|
|
|
for (MesTimeEfficientCfg bean : beanList) {
|
|
|
|
|
|
|
|
ConvertBean.serviceModelInitialize(bean, userName);
|
|
|
|
|
|
|
|
bean.setOrganizeCode(organizeCode);
|
|
|
|
|
|
|
|
bean.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
baseService.insertBatch(beanList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 导入后
|
|
|
|
|
|
|
|
afterImport(beanList);
|
|
|
|
|
|
|
|
return ResultBean.success("导入成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
|
|
|
return ResultBean.fail(e);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|