rev:工单导入/缓存线物料更新
This commit is contained in:
@@ -21,9 +21,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.*;
|
||||
@@ -146,12 +144,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importExcel(String path) {
|
||||
WQLObject measureunitTab = WQLObject.getWQLObject("md_pb_measureunit");
|
||||
WQLObject materialbaseTab = WQLObject.getWQLObject("md_me_materialbase");
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
//List<Map<String, Object>> listMap = EasyExcel.read(path).sheet(1).doReadSync();
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
for (int i = 3; i < listMap.size(); i++) {
|
||||
Map<String, Object> map = listMap.get(i);
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.nl.wms.device_manage.controller.userdevice;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 人员设备关系表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-06-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pdmBiPersoncorrdevice")
|
||||
public class PdmBiPersoncorrdeviceController {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
|
||||
package org.nl.wms.mps.rest;
|
||||
package org.nl.wms.device_manage.controller.userdevice;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.jsonwebtoken.lang.Assert;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.wms.device_manage.service.userdevice.IPdmBiPersoncorrdeviceService;
|
||||
import org.nl.wms.device_manage.service.userdevice.dao.PdmBiPersoncorrdevice;
|
||||
import org.nl.wms.mps.service.PersoncorrdeviceService;
|
||||
import org.nl.wms.mps.service.dto.PersoncorrdeviceDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -16,6 +24,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -30,50 +40,43 @@ import java.util.Map;
|
||||
public class PersoncorrdeviceController {
|
||||
|
||||
private final PersoncorrdeviceService personcorrdeviceService;
|
||||
private final IPdmBiPersoncorrdeviceService pdmBiPersoncorrdeviceService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询人员设备维护")
|
||||
@ApiOperation("查询人员设备维护")
|
||||
//@PreAuthorize("@el.check('personcorrdevice:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
|
||||
return new ResponseEntity<>(personcorrdeviceService.queryAll(whereJson,page),HttpStatus.OK);
|
||||
public ResponseEntity<Object> query(@RequestParam Map query, PageQuery page){
|
||||
Page<Object> result = PageHelper.startPage(page.getPage() + 1, page.getSize());
|
||||
List<Map> list = pdmBiPersoncorrdeviceService.queryAll(query);
|
||||
TableDataInfo build = TableDataInfo.build(list);
|
||||
build.setTotalElements(result.getTotal());
|
||||
return new ResponseEntity<>(build,HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增人员设备维护")
|
||||
@ApiOperation("新增人员设备维护")
|
||||
//@PreAuthorize("@el.check('personcorrdevice:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody PersoncorrdeviceDto dto){
|
||||
personcorrdeviceService.create(dto);
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject entity){
|
||||
Assert.notNull(entity,"请求参数不能为空");
|
||||
PdmBiPersoncorrdevice pdmBiPersoncorrdevice = entity.toJavaObject(PdmBiPersoncorrdevice.class);
|
||||
pdmBiPersoncorrdevice.setId(IdUtil.getStringId());
|
||||
pdmBiPersoncorrdeviceService.save(pdmBiPersoncorrdevice);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改人员设备维护")
|
||||
@ApiOperation("修改人员设备维护")
|
||||
//@PreAuthorize("@el.check('personcorrdevice:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody PersoncorrdeviceDto dto){
|
||||
personcorrdeviceService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除人员设备维护")
|
||||
@ApiOperation("删除人员设备维护")
|
||||
//@PreAuthorize("@el.check('personcorrdevice:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
personcorrdeviceService.deleteAll(ids);
|
||||
if (ids != null && ids.length>0){
|
||||
pdmBiPersoncorrdeviceService.removeByIds(Arrays.asList(ids));
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/addPersons")
|
||||
@Log("添加人员")
|
||||
@ApiOperation("添加人员")
|
||||
//@PreAuthorize("@el.check('teamcorrperson:list')")
|
||||
public ResponseEntity<Object> addPersons(@RequestBody JSONObject param) {
|
||||
personcorrdeviceService.addPersons(param);
|
||||
return new ResponseEntity<>( HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getDeviceByPerson")
|
||||
@Log("查询设备")
|
||||
@@ -1,7 +1,15 @@
|
||||
package org.nl.wms.device_manage.service.userdevice;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.device_manage.service.userdevice.dao.PdmBiPersoncorrdevice;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.wms.mps.service.dto.PersoncorrdeviceDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +21,63 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IPdmBiPersoncorrdeviceService extends IService<PdmBiPersoncorrdevice> {
|
||||
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
List<Map> queryAll(Map whereJson);
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param team_person_device_id ID
|
||||
* @return Personcorrdevice
|
||||
*/
|
||||
PersoncorrdeviceDto findById(Long team_person_device_id);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
* @param code code
|
||||
* @return Personcorrdevice
|
||||
*/
|
||||
PersoncorrdeviceDto findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param dto /
|
||||
*/
|
||||
void create(PersoncorrdeviceDto dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param dto /
|
||||
*/
|
||||
void update(PersoncorrdeviceDto dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
void addPersons(JSONObject param);
|
||||
|
||||
/**
|
||||
* 设备
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> getDeviceByPerson(Map whereJson, Pageable page);
|
||||
|
||||
Map<String, Object> getHeader(JSONObject param);
|
||||
|
||||
JSONArray getDeviceIdByUserId(JSONObject param);
|
||||
|
||||
void addDevices(JSONObject param);
|
||||
|
||||
void deleteRow(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.device_manage.service.userdevice.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
@@ -20,6 +21,8 @@ public class PdmBiPersoncorrdevice implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id")
|
||||
private String id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,9 @@ package org.nl.wms.device_manage.service.userdevice.dao.mapper;
|
||||
import org.nl.wms.device_manage.service.userdevice.dao.PdmBiPersoncorrdevice;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 人员设备关系表 Mapper 接口
|
||||
@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface PdmBiPersoncorrdeviceMapper extends BaseMapper<PdmBiPersoncorrdevice> {
|
||||
|
||||
List<Map> queryAll(Map query);
|
||||
}
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.device_manage.service.userdevice.dao.mapper.PdmBiPersoncorrdeviceMapper">
|
||||
|
||||
<select id="queryAll" resultType="java.util.Map">
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package org.nl.wms.device_manage.service.userdevice.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.device_manage.service.userdevice.dao.PdmBiPersoncorrdevice;
|
||||
import org.nl.wms.device_manage.service.userdevice.dao.mapper.PdmBiPersoncorrdeviceMapper;
|
||||
import org.nl.wms.device_manage.service.userdevice.IPdmBiPersoncorrdeviceService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.wms.mps.service.dto.PersoncorrdeviceDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 人员设备关系表 服务实现类
|
||||
@@ -17,4 +25,64 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class PdmBiPersoncorrdeviceServiceImpl extends ServiceImpl<PdmBiPersoncorrdeviceMapper, PdmBiPersoncorrdevice> implements IPdmBiPersoncorrdeviceService {
|
||||
|
||||
@Override
|
||||
public List<Map> queryAll(Map query) {
|
||||
this.baseMapper.queryAll(query);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersoncorrdeviceDto findById(Long team_person_device_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersoncorrdeviceDto findByCode(String code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(PersoncorrdeviceDto dto) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PersoncorrdeviceDto dto) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Long[] ids) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPersons(JSONObject param) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDeviceByPerson(Map whereJson, Pageable page) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getHeader(JSONObject param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDeviceIdByUserId(JSONObject param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDevices(JSONObject param) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRow(JSONObject param) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package org.nl.wms.ext.sap.rest;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -30,6 +31,7 @@ import java.util.Map;
|
||||
@Api(tags = "wms发送sap")
|
||||
@RequestMapping("/api/sap/")
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
public class WmsToSapController {
|
||||
private final WmsToSapService wmsToSapService;
|
||||
|
||||
@@ -50,6 +52,7 @@ public class WmsToSapController {
|
||||
@PostMapping("/getDeliveryNote")
|
||||
@Log("获取物料基础信息")
|
||||
@ApiOperation("获取物料基础信息")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getDeliveryNote(@RequestBody JSONObject form) {
|
||||
return new ResponseEntity<>(wmsToSapService.getDeliveryNote(form), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -216,6 +216,10 @@ public class SpeFullTask extends AbstractAcsTask {
|
||||
taskService.update(wrapper);
|
||||
//outboxt箱子更新到任务表vechile_code2?
|
||||
if (extParam.get("inbox") != null){
|
||||
List<SchCachelineVehilematerial> list = cacheLineVechileService.list(new QueryWrapper<SchCachelineVehilematerial>().eq("vehicle_code", extParam.get("inbox")));
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
cacheLineVechileService.removeByIds(list.stream().map(SchCachelineVehilematerial::getVehmaterial_id).collect(Collectors.toList()));
|
||||
}
|
||||
SchCachelineVehilematerial vehilematerial = new SchCachelineVehilematerial();
|
||||
vehilematerial.setCreate_time(DateUtil.now());
|
||||
vehilematerial.setVehmaterial_id(IdUtil.getStringId());
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -14,8 +15,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.jsonwebtoken.lang.Assert;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
@@ -30,6 +35,7 @@ import org.nl.wms.masterdata_manage.master.service.classstandard.IMdPbClassstand
|
||||
import org.nl.wms.masterdata_manage.service.material.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.masterdata_manage.service.material.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.mps.service.WorkOrderImportEnum;
|
||||
import org.nl.wms.mps.service.dto.ProduceWorkorderDto;
|
||||
import org.nl.wms.mps.service.dto.ProduceshiftorderDto;
|
||||
import org.nl.wms.product_manage.ReportEnum;
|
||||
import org.nl.wms.product_manage.service.device.IPdmBiDeviceService;
|
||||
@@ -42,6 +48,8 @@ import org.nl.wms.product_manage.service.workorder.dao.WorkorderRecord;
|
||||
import org.nl.wms.product_manage.service.workorder.dao.mapper.PdmProduceWorkorderMapper;
|
||||
import org.nl.wms.product_manage.service.workorder.dto.ReportQuery;
|
||||
import org.nl.wms.product_manage.service.workorder.dto.WorkorderQuery;
|
||||
import org.nl.wms.product_manage.service.workprocedure.IPdmBiWorkprocedureService;
|
||||
import org.nl.wms.product_manage.service.workprocedure.dao.PdmBiWorkprocedure;
|
||||
import org.nl.wms.system_manage.service.user.ISysUserService;
|
||||
import org.nl.wms.system_manage.service.user.dao.SysUser;
|
||||
import org.redisson.misc.Hash;
|
||||
@@ -55,9 +63,12 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -84,6 +95,8 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
@Resource
|
||||
private PdmProduceWorkorderMapper pdmProduceWorkorderMapper;
|
||||
@Resource
|
||||
private IPdmBiWorkprocedureService workprocedureService;
|
||||
@Resource
|
||||
private IPdmProduceWorkorderrecordService reportRecordService;
|
||||
|
||||
@Override
|
||||
@@ -227,287 +240,130 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
// todo: 根据需求修改
|
||||
if (file.isEmpty()) {
|
||||
throw new BadRequestException("文件为空,请添加数据后重新导入");
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
// 1.获取上传文件输入流
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
//A1_TW_+device_code 日期2023/5/30
|
||||
//material_spec='24030921S'
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream,"推弯计划表");
|
||||
List<List<Object>> read = excelReader.read();
|
||||
String produce_date = "";
|
||||
// 循环获取的数据
|
||||
List<PdmProduceWorkorder> data = new ArrayList<>();
|
||||
row:
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
continue;
|
||||
}
|
||||
//获取每列
|
||||
JSONObject param = new JSONObject();
|
||||
//按照列获取
|
||||
param.put("workorder_id", IdUtil.getStringId());
|
||||
param.put("workorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
param.put("workorder_status", WorkerOrderEnum.CREATE.getCode());
|
||||
param.put("shift_type_scode", StatusEnum.DAYSHIFT.getCode()); // 默认白班
|
||||
String error_message = "";
|
||||
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
|
||||
workorder.setWorkorder_id(IdUtil.getStringId());
|
||||
workorder.setWorkorder_code(CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
workorder.setWorkorder_status(WorkerOrderEnum.CREATE.getCode());
|
||||
workorder.setIs_needmove(true);
|
||||
workorder.setIs_canupdate_update(true);
|
||||
workorder.setCreate_time(DateUtil.now());
|
||||
workorder.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
workorder.setCreate_name("导入订单");
|
||||
workorder.setCreate_type(StatusEnum.EXCELINTO.getCode());
|
||||
|
||||
Map<String,String> errorMap = new HashMap();
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
String col = String.valueOf(list.get(j));
|
||||
解析cell:{ //如果是第一行 为生产日期
|
||||
if (i == 0 && j == 0) {
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if (j == 0 && col.contains("班次")) {
|
||||
continue row;
|
||||
}
|
||||
if (j == 0) {
|
||||
//物料
|
||||
workorder.setShift_type_scode(col.equals("夜班") ? "0" : "1");
|
||||
}
|
||||
if (j == 1) {
|
||||
//物料
|
||||
workorder.setPlanproduceend_date(col.substring(0,col.indexOf(" "))+" 18:30:00");
|
||||
workorder.setPlanproducestart_date(col.substring(0,col.indexOf(" "))+" 07:30:00");
|
||||
}
|
||||
if (j == 2) {
|
||||
//物料
|
||||
List<MdMeMaterialbase> material_specs = materialbaseService.list(new QueryWrapper<MdMeMaterialbase>().eq("material_spec", col));
|
||||
if (CollectionUtils.isEmpty(material_specs)) {
|
||||
errorMap.put("第" + i + "行" + col, "物料规格对应物料信息不存在");
|
||||
error_message = error_message + col + "物料规格对应物料信息不存在,";
|
||||
} else {
|
||||
Optional<MdMeMaterialbase> first = material_specs.stream().filter(new Predicate<MdMeMaterialbase>() {
|
||||
@Override
|
||||
public boolean test(MdMeMaterialbase mdMeMaterialbase) {
|
||||
return mdMeMaterialbase.getMaterial_code().contains("S") && !mdMeMaterialbase.getMaterial_code().contains("TH");
|
||||
}
|
||||
}).findFirst();
|
||||
if (!first.isPresent()) {
|
||||
errorMap.put("第" + i + "行" + col, "物料规格对应物料信息不存在");
|
||||
}
|
||||
workorder.setMaterial_id(first.get().getMaterial_id());
|
||||
}
|
||||
}
|
||||
if (j == 3) {
|
||||
PdmBiWorkprocedure workprocedure = workprocedureService.getOne(new QueryWrapper<PdmBiWorkprocedure>().eq("workprocedure_name", col));
|
||||
if (ObjectUtil.isEmpty(workprocedure)) {
|
||||
errorMap.put("第" + i + "行" + col, "工序名称是否正确");
|
||||
} else {
|
||||
workorder.setWorkprocedure_id(workprocedure.getWorkprocedure_id());
|
||||
}
|
||||
}
|
||||
if (j == 4) {
|
||||
//设备 A1_TW_
|
||||
workorder.setDevice_code("A1_TW_" + col);
|
||||
}
|
||||
if (j == 7) {
|
||||
//单重
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.valueOf(col) * 1000);
|
||||
workorder.setMaterial_weight(bigDecimal.setScale(3, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (j == 8) {
|
||||
//操作工
|
||||
SysUser user = userService.getOne(new QueryWrapper<SysUser>().eq("username", col));
|
||||
if (ObjectUtil.isEmpty(user)) {
|
||||
errorMap.put("第" + i + "行" + col, " 操作工没有账号");
|
||||
} else {
|
||||
workorder.setCurrent_produce_person_id(user.getUser_id());
|
||||
}
|
||||
}
|
||||
if (j == 9) {
|
||||
workorder.setPlan_qty(new BigDecimal(Long.valueOf(col)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(errorMap)){
|
||||
data.add(workorder);
|
||||
}else {
|
||||
throw new BadRequestException(JSON.toJSONString(errorMap));
|
||||
}
|
||||
}
|
||||
this.saveBatch(data);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ExcelReader reader = ExcelUtil.getReader(inputStream);
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream, 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
String produce_date = "";
|
||||
// 循环获取的数据
|
||||
List<PdmProduceWorkorder> entitys = new ArrayList<>();
|
||||
row:
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
continue;
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}finally {
|
||||
if (inputStream !=null){
|
||||
try {
|
||||
inputStream.close();
|
||||
}catch (Exception ex){ }
|
||||
}
|
||||
//获取每列
|
||||
JSONObject param = new JSONObject();
|
||||
//按照列获取
|
||||
param.put("workorder_id", cn.hutool.core.util.IdUtil.getSnowflake(1, 1).nextId());
|
||||
param.put("workorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
// param.put("macoperate_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
param.put("workorder_status", WorkerOrderEnum.CREATE.getCode());
|
||||
param.put("shift_type_scode", StatusEnum.DAYSHIFT.getCode()); // 默认白班
|
||||
String is_error = "0";
|
||||
String error_message = "";
|
||||
//循环每一行
|
||||
col:
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
|
||||
String col = String.valueOf(list.get(j));
|
||||
//如果是第一行 为生产日期
|
||||
if (i == 0 && j == 0) {
|
||||
produce_date = col.split(":")[col.split(":").length - 1];
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if (j == 0 && col.contains("规格名称")) {
|
||||
continue row;
|
||||
}
|
||||
if (j == 0) {
|
||||
//物料
|
||||
if (StrUtil.isEmpty(col)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "物料规格为空,";
|
||||
}
|
||||
MdMeMaterialbase material = materialbaseService.getOne(new QueryWrapper<MdMeMaterialbase>().eq("material_spec", col));
|
||||
if (ObjectUtil.isEmpty(material)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "物料规格对应物料信息不存在,";
|
||||
} else {
|
||||
param.put("material_id", material.getMaterial_id());
|
||||
}
|
||||
}
|
||||
if (j == 2) {
|
||||
if (StrUtil.isEmpty(col)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "工序名称为空,";
|
||||
}
|
||||
WorkOrderImportEnum idByName = WorkOrderImportEnum.getIdByName(col);
|
||||
if (ObjectUtil.isEmpty(idByName)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "工序名称是否正确,";
|
||||
} else {
|
||||
param.put("workprocedure_id", idByName.getId());
|
||||
}
|
||||
}
|
||||
if (j == 4) {
|
||||
//单重
|
||||
param.put("material_weight", col);
|
||||
}
|
||||
if (j == 6) {
|
||||
if (StrUtil.isEmpty(col)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "工单计划数量为空,";
|
||||
} else {
|
||||
param.put("plan_qty", col);
|
||||
}
|
||||
}
|
||||
if (j == 10) {
|
||||
String workprocedure_id = param.getString("workprocedure_id");
|
||||
PdmBiDevice device = deviceService.getOne(new QueryWrapper<PdmBiDevice>().eq("device_code", col));
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "设备编码不存在,";
|
||||
}
|
||||
if (!workprocedure_id.equals(device.getWorkprocedure_id())) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "设备与所属工序不匹配,";
|
||||
} else {
|
||||
param.put("device_code", device.getDevice_code());
|
||||
}
|
||||
}
|
||||
if (j == 11) {
|
||||
SysUser jsonUser = userService.getOne(new QueryWrapper<SysUser>().eq("username", col));
|
||||
if (ObjectUtil.isEmpty(jsonUser)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "生产人员编码不存在!";
|
||||
} else {
|
||||
param.put("current_produce_person_id", jsonUser.getUser_id());
|
||||
}
|
||||
}
|
||||
if (j == 12) {
|
||||
//允许修改报工数量
|
||||
String is_canupdate = "0";
|
||||
if (col.equals("是")) {
|
||||
is_canupdate = "1";
|
||||
}
|
||||
param.put("is_canupdate_update", is_canupdate);
|
||||
}
|
||||
if (j == 13) {
|
||||
//是否agv搬运
|
||||
String needmoce = "0";
|
||||
if (col.equals("是")) {
|
||||
needmoce = "1";
|
||||
}
|
||||
param.put("is_needmove", needmoce);
|
||||
}
|
||||
}
|
||||
param.put("is_error", is_error);
|
||||
param.put("error_info", error_message);
|
||||
param.put("create_type", StatusEnum.EXCELINTO.getCode());
|
||||
param.put("planproducestart_date", produce_date + "07:30:00");
|
||||
param.put("planproduceend_date", produce_date + "18:30:00");
|
||||
param.put("create_id", currentUserId);
|
||||
param.put("create_name", nickName);
|
||||
param.put("create_time", DateUtil.now());
|
||||
entitys.add(param.toJavaObject(PdmProduceWorkorder.class));
|
||||
}
|
||||
|
||||
// 1.获取上传文件输入流
|
||||
inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//读取夜班工单数据
|
||||
excelReader = ExcelUtil.getReader(inputStream, 1);
|
||||
read = excelReader.read(0, excelReader.getRowCount());
|
||||
String is_error = "0";
|
||||
String error_message = "";
|
||||
// 循环获取的数据
|
||||
row:
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
//获取每列
|
||||
JSONObject param = new JSONObject();
|
||||
//按照列获取
|
||||
param.put("workorder_id", cn.hutool.core.util.IdUtil.getSnowflake(1, 1).nextId());
|
||||
param.put("workorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
// param.put("producedeviceorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
param.put("workorder_status", WorkerOrderEnum.CREATE.getCode());
|
||||
// param.put("produce_date", produce_date);
|
||||
param.put("shift_type_scode", StatusEnum.NIGHTSHIFT.getCode()); // 夜班
|
||||
//循环每一行
|
||||
col:
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
|
||||
String col = String.valueOf(list.get(j));
|
||||
//如果是第一行 为生产日期
|
||||
if (i == 0 && j == 0) {
|
||||
produce_date = col.split(":")[col.split(":").length - 1];
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if (j == 0 && col.contains("规格名称")) {
|
||||
continue row;
|
||||
}
|
||||
if (j == 0) {
|
||||
//物料
|
||||
if (StrUtil.isEmpty(col)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "物料规格为空,";
|
||||
}
|
||||
MdMeMaterialbase material = materialbaseService.getOne(new QueryWrapper<MdMeMaterialbase>().eq("material_spec", col));
|
||||
if (ObjectUtil.isEmpty(material)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "物料规格对应物料信息不存在,";
|
||||
} else {
|
||||
param.put("material_id", material.getMaterial_id());
|
||||
}
|
||||
}
|
||||
if (j == 2) {
|
||||
if (StrUtil.isEmpty(col)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "工序名称为空,";
|
||||
}
|
||||
WorkOrderImportEnum idByName = WorkOrderImportEnum.getIdByName(col);
|
||||
if (ObjectUtil.isEmpty(idByName)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "工序名称是否正确,";
|
||||
} else {
|
||||
param.put("workprocedure_id", idByName.getId());
|
||||
}
|
||||
}
|
||||
if (j == 4) {
|
||||
//单重
|
||||
param.put("material_weight", col);
|
||||
}
|
||||
if (j == 6) {
|
||||
if (StrUtil.isEmpty(col)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "工单计划数量为空,";
|
||||
} else {
|
||||
param.put("plan_qty", col);
|
||||
}
|
||||
}
|
||||
// if (j == 10) {
|
||||
// //物料
|
||||
// JSONObject json_material = wo_material.query("is_delete = '0' and material_code = '" + col + "'").uniqueResult(0);
|
||||
// if (ObjectUtil.isEmpty(json_material)) {
|
||||
// throw new BadRequestException("第'" + (i + 2) + "'行,物料编码不存在");
|
||||
// }
|
||||
// param.put("material_id", json_material.getString("material_id"));
|
||||
// }
|
||||
if (j == 10) {
|
||||
String workprocedure_id = param.getString("workprocedure_id");
|
||||
PdmBiDevice device = deviceService.getOne(new QueryWrapper<PdmBiDevice>().eq("device_code", col));
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "设备编码不存在,";
|
||||
}
|
||||
if (!workprocedure_id.equals(device.getWorkprocedure_id())) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "设备与所属工序不匹配,";
|
||||
} else {
|
||||
param.put("device_code", device.getDevice_code());
|
||||
}
|
||||
}
|
||||
if (j == 11) {
|
||||
SysUser jsonUser = userService.getOne(new QueryWrapper<SysUser>().eq("username", col));
|
||||
if (ObjectUtil.isEmpty(jsonUser)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "生产人员编码不存在!";
|
||||
} else {
|
||||
param.put("current_produce_person_id", jsonUser.getUser_id());
|
||||
}
|
||||
}
|
||||
if (j == 12) {
|
||||
//允许修改报工数量
|
||||
String is_canupdate = "0";
|
||||
if (col.equals("是")) {
|
||||
is_canupdate = "1";
|
||||
}
|
||||
param.put("is_canupdate_update", is_canupdate);
|
||||
}
|
||||
if (j == 13) {
|
||||
//是否agv搬运
|
||||
String needmoce = "0";
|
||||
if (col.equals("是")) {
|
||||
needmoce = "1";
|
||||
}
|
||||
param.put("is_needmove", needmoce);
|
||||
}
|
||||
}
|
||||
param.put("is_error", is_error);
|
||||
param.put("error_info", error_message);
|
||||
param.put("create_type", StatusEnum.EXCELINTO.getCode());
|
||||
param.put("planproducestart_date", produce_date + "18:30:00");
|
||||
DateTime dateTime = DateUtil.offsetDay(DateUtil.parse(produce_date), 1);
|
||||
param.put("planproduceend_date", DateUtil.format(dateTime, "yyyy-MM-dd") + " 07:30:00");
|
||||
param.put("create_id", currentUserId);
|
||||
param.put("create_name", nickName);
|
||||
param.put("create_time", DateUtil.now());
|
||||
entitys.add(param.toJavaObject(PdmProduceWorkorder.class));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(entitys)) {
|
||||
this.saveBatch(entitys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ spring:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.46.5}:${DB_PORT:3306}/${DB_NAME:hl_one_mes_test}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.46.5}:${DB_PORT:3306}/${DB_NAME:hl_one_mes_test}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.46.5}:${DB_PORT:3306}/${DB_NAME:hl_one_mes_test}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:123456}
|
||||
password: ${DB_PWD:123456}
|
||||
password: ${DB_PWD:942464Yy}
|
||||
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
|
||||
Reference in New Issue
Block a user