rev:设备台账功能修改
This commit is contained in:
@@ -296,6 +296,7 @@ public class EmBiIostorinvOutServiceImpl extends ServiceImpl<EmBiIostorinvOutMap
|
||||
stIvtIostorinvYl.setDetail_count(rows.size());
|
||||
stIvtIostorinvYl.setRemark(whereJson.getString("remark"));
|
||||
stIvtIostorinvYl.setWorkshop_id(whereJson.getString("workshop_id"));
|
||||
stIvtIostorinvYl.setSource_id(whereJson.getString("source_id"));
|
||||
|
||||
return stIvtIostorinvYl;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.device_manage.ios.service.iostorInv.EmBiIostorinvOutService;
|
||||
import org.nl.wms.device_manage.repair.service.DevicerepairmstService;
|
||||
import org.nl.wms.device_manage.repair.service.dto.DevicerepairmstDto;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtBsrealstorattrService;
|
||||
@@ -49,6 +50,9 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
// private final StorattrService storattrService;
|
||||
// private final SparePartOutServiceImpl sparePartOutService;
|
||||
|
||||
@Autowired
|
||||
private EmBiIostorinvOutService emBiIostorinvOutService;
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@@ -169,6 +173,7 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
jsonMst.put("remark", whereJson.getString("remark"));
|
||||
jsonMst.put("plan_start_date", whereJson.getString("plan_start_date"));
|
||||
jsonMst.put("detail_count", tableData.size());
|
||||
jsonMst.put("update_optname", whereJson.getString("update_optname"));
|
||||
jsonMst.put("input_optid", currentUserId);
|
||||
jsonMst.put("input_optname", nickName);
|
||||
jsonMst.put("input_time", DateUtil.now());
|
||||
@@ -208,6 +213,7 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
jsonMst.put("remark", whereJson.getString("remark"));
|
||||
jsonMst.put("plan_start_date", whereJson.getString("plan_start_date"));
|
||||
jsonMst.put("estimaterepair_times", whereJson.getString("estimaterepair_times"));
|
||||
jsonMst.put("update_optname", whereJson.getString("update_optname"));
|
||||
jsonMst.put("detail_count", tableData.size());
|
||||
mstTab.update(jsonMst);
|
||||
|
||||
@@ -260,8 +266,8 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_DeviceRepairMst");
|
||||
WQLObject dtlTab = WQLObject.getWQLObject("EM_BI_DeviceRepairDtl");
|
||||
|
||||
JSONArray resultJSONArray = dtlTab.query("repair_id = '" + whereJson.getString("repair_id") + "'").getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(resultJSONArray)) throw new BadRequestException("维修项目为空");
|
||||
/* JSONArray resultJSONArray = dtlTab.query("repair_id = '" + whereJson.getString("repair_id") + "'").getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(resultJSONArray)) throw new BadRequestException("维修项目为空");*/
|
||||
|
||||
JSONObject json = mstTab.query("repair_id ='" + whereJson.getString("repair_id") + "'").uniqueResult(0);
|
||||
json.put("invstatus", "02");
|
||||
@@ -283,7 +289,7 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
JSONObject jsonReMst = reMstTab.query("repair_id = '" + whereJson.getString("repair_id") + "'").uniqueResult(0);
|
||||
jsonReMst.put("invstatus", "03");
|
||||
jsonReMst.put("estimaterepair_times", whereJson.getString("estimaterepair_times"));
|
||||
jsonReMst.put("update_optname", whereJson.getString("update_optname"));
|
||||
// jsonReMst.put("update_optname", whereJson.getString("update_optname"));
|
||||
jsonReMst.put("real_start_date", DateUtil.now());
|
||||
reMstTab.update(jsonReMst);
|
||||
// 2.更新设备档案表
|
||||
@@ -322,7 +328,9 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void endRepair(JSONObject whereJson) {
|
||||
public void endRepair(JSONObject whereJson2) {
|
||||
JSONObject whereJson = whereJson2.getJSONObject("form");
|
||||
|
||||
Long currentUserId = Long.parseLong(SecurityUtils.getCurrentUserId());
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
@@ -374,6 +382,7 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
JSONObject jsonReMst = reMstTab.query("repair_id = '" + whereJson.getString("repair_id") + "'").uniqueResult(0);
|
||||
jsonReMst.put("invstatus", "06");
|
||||
jsonReMst.put("real_end_date", DateUtil.now());
|
||||
jsonReMst.put("update_optname", whereJson.getString("update_optname"));
|
||||
jsonReMst.put("confirm_optid", currentUserId);
|
||||
jsonReMst.put("confirm_optname", nickName);
|
||||
jsonReMst.put("confirm_time", DateUtil.now());
|
||||
@@ -397,6 +406,28 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
jsonLife.put("create_name",nickName);
|
||||
jsonLife.put("create_time", DateUtil.now());
|
||||
lifeTab.insert(jsonLife);
|
||||
|
||||
// 5.判断是否需要新增备件出库单
|
||||
Boolean aSwitch = whereJson.getBoolean("switch");
|
||||
if (ObjectUtil.isEmpty(aSwitch)) aSwitch = false;
|
||||
if (aSwitch) {
|
||||
whereJson2.put("repair_code", jsonReMst.getString("repair_code"));
|
||||
this.createIos(whereJson2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createIos(JSONObject whereJson) {
|
||||
JSONObject mst = whereJson.getJSONObject("form2");
|
||||
JSONArray tableDataDtl = mst.getJSONArray("tableDataDtl");
|
||||
|
||||
// 准备参数
|
||||
mst.put("biz_date", DateUtil.now());
|
||||
mst.put("tableData", tableDataDtl);
|
||||
mst.put("source_id", whereJson.getString("repair_code"));
|
||||
mst.put("remark", "由维修单创建");
|
||||
|
||||
emBiIostorinvOutService.create(mst);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -407,19 +438,27 @@ public class DevicerepairmstServiceImpl implements DevicerepairmstService {
|
||||
WQLObject reMstTab = WQLObject.getWQLObject("EM_BI_DeviceRepairMst"); // 设备维修单主表
|
||||
WQLObject reDtlTab = WQLObject.getWQLObject("EM_BI_DeviceRepairDtl"); // 设备维修单明细表
|
||||
WQLObject recordTab = WQLObject.getWQLObject("EM_BI_DeviceRepairRecord"); // 设备维修单情况记录表
|
||||
WQLObject itemTab = WQLObject.getWQLObject("em_bi_devicerepairitems"); // 设备维修项目表
|
||||
|
||||
// 1.更新维修主表
|
||||
JSONObject jsonReMst = reMstTab.query("repair_id = '" + whereJson.getString("repair_id") + "'").uniqueResult(0);
|
||||
// jsonReMst.put("update_optname", whereJson.getString("update_optname"));
|
||||
jsonReMst.put("update_optname", whereJson.getString("update_optname"));
|
||||
jsonReMst.put("product_person_name", whereJson.getString("product_person_name"));
|
||||
jsonReMst.put("update_time", DateUtil.now());
|
||||
reMstTab.update(jsonReMst);
|
||||
// 2.更新明细表
|
||||
|
||||
// 2.删除所有明细重新插入
|
||||
reDtlTab.delete("repair_id = '"+whereJson.getString("repair_id")+"'");
|
||||
|
||||
for (int i = 0; i < tableData.size(); i++) {
|
||||
JSONObject json = tableData.getJSONObject(i);
|
||||
JSONObject jsonRedtl = reDtlTab.query("repair_dtl_id = '" + json.getString("repair_dtl_id") + "'").uniqueResult(0);
|
||||
jsonRedtl.put("isfinish", json.getString("isfinish"));
|
||||
reDtlTab.update(jsonRedtl);
|
||||
JSONObject jsonObject = tableData.getJSONObject(i);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("repair_dtl_id", org.nl.common.utils.IdUtil.getStringId());
|
||||
json.put("repair_id", whereJson.getString("repair_id"));
|
||||
json.put("repair_item_id", jsonObject.getString("repair_item_id"));
|
||||
json.put("isfinish", jsonObject.getString("isfinish"));
|
||||
reDtlTab.insert(json);
|
||||
}
|
||||
|
||||
// 3.插入设备维修单情况记录表
|
||||
|
||||
@@ -10,6 +10,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
@@ -21,6 +22,8 @@ import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.device_manage.repair.service.DevicerepairrequestService;
|
||||
import org.nl.wms.device_manage.repair.service.dto.DevicerepairrequestDto;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.masterdata_manage.service.em.EmBiRepairDeviceService;
|
||||
import org.nl.wms.masterdata_manage.service.em.dao.EmBiRepairDevice;
|
||||
import org.nl.wms.system_manage.service.dept.ISysDeptService;
|
||||
import org.nl.wms.system_manage.service.user.ISysUserService;
|
||||
import org.nl.wms.system_manage.service.user.dao.SysUser;
|
||||
@@ -50,6 +53,9 @@ public class DevicerepairrequestServiceImpl implements DevicerepairrequestServic
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private EmBiRepairDeviceService emBiRepairDeviceService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
|
||||
@@ -272,7 +278,15 @@ public class DevicerepairrequestServiceImpl implements DevicerepairrequestServic
|
||||
jsonRequest.put("process_time", DateUtil.now());
|
||||
requestTab.update(jsonRequest);
|
||||
|
||||
// 3.插入设备维修单主表
|
||||
// 3.判断此设备是否有对应的维修人
|
||||
List<EmBiRepairDevice> repairDeviceDaoList = emBiRepairDeviceService.list(
|
||||
new QueryWrapper<EmBiRepairDevice>().lambda()
|
||||
.eq(EmBiRepairDevice::getDevice_code, jsonFile.getString("device_code"))
|
||||
);
|
||||
|
||||
if (repairDeviceDaoList.size() > 1) throw new BadRequestException("此设备对应维修人员超过2人,请检查!");
|
||||
|
||||
// 4.插入设备维修单主表
|
||||
JSONObject jsonReMst = new JSONObject();
|
||||
jsonReMst.put("repair_id", IdUtil.getSnowflake(1,1).nextId());
|
||||
jsonReMst.put("repair_code", CodeUtil.getNewCode("REPAIR_CODE"));
|
||||
@@ -292,6 +306,10 @@ public class DevicerepairrequestServiceImpl implements DevicerepairrequestServic
|
||||
jsonReMst.put("input_time", DateUtil.now());
|
||||
jsonReMst.put("sysdeptid", 1);
|
||||
jsonReMst.put("syscompanyid",1);
|
||||
if (ObjectUtil.isNotEmpty(repairDeviceDaoList)){
|
||||
SysUser userDao = iSysUserService.getById(repairDeviceDaoList.get(0).getUser_id());
|
||||
jsonReMst.put("update_optname", userDao.getPerson_name());
|
||||
}
|
||||
reMstTab.insert(jsonReMst);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,4 +48,10 @@ public class DevicePairQueryController {
|
||||
return new ResponseEntity<>(devicePairQueryService.getDeviceInfo(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getIosMst")
|
||||
@ApiOperation("获取备件出库单信息")
|
||||
public ResponseEntity<Object> getIosMst(@RequestBody JSONObject whereJson){
|
||||
return new ResponseEntity<>(devicePairQueryService.getIosMst(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,4 +32,7 @@ public interface DevicePairQueryService {
|
||||
* @return JSONObject
|
||||
*/
|
||||
JSONObject getDeviceInfo(JSONObject whereJson);
|
||||
|
||||
JSONObject getIosMst(JSONObject whereJson);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,13 +5,17 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.device_manage.ios.service.iostorInv.EmBiIostorinvOutService;
|
||||
import org.nl.wms.device_manage.ios.service.iostorInv.dao.EmBiostorinv;
|
||||
import org.nl.wms.device_manage.stat.service.DevicePairQueryService;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.system_manage.service.dept.ISysDeptService;
|
||||
@@ -33,6 +37,9 @@ public class DevicePairQueryServiceImpl implements DevicePairQueryService {
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private EmBiIostorinvOutService emBiIostorinvOutService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
|
||||
@@ -194,4 +201,13 @@ public class DevicePairQueryServiceImpl implements DevicePairQueryService {
|
||||
json.put("tableData2", relArr);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getIosMst(JSONObject whereJson) {
|
||||
EmBiostorinv dao = emBiIostorinvOutService.getOne(
|
||||
new QueryWrapper<EmBiostorinv>().lambda()
|
||||
.eq(EmBiostorinv::getSource_id, whereJson.getString("repair_code"))
|
||||
);
|
||||
return JSON.parseObject(JSONObject.toJSONString(dao));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.tools.domain.LocalStorage;
|
||||
@@ -20,6 +22,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@@ -34,7 +37,7 @@ public class EquipmentfileController {
|
||||
private final EquipmentfileService equipmentfileService;
|
||||
private final LocalStorageService localStorageService;
|
||||
@GetMapping
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
|
||||
return new ResponseEntity<>(equipmentfileService.queryAll(whereJson,page),HttpStatus.OK);
|
||||
}
|
||||
@@ -46,20 +49,20 @@ public class EquipmentfileController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("新增工令")
|
||||
@ApiOperation("新增设备档案")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject json){
|
||||
equipmentfileService.create(json);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("修改工令")
|
||||
@ApiOperation("修改设备档案")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson){
|
||||
equipmentfileService.update(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("删除工令")
|
||||
@ApiOperation("删除设备档案")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
equipmentfileService.deleteAll(ids);
|
||||
@@ -74,48 +77,48 @@ public class EquipmentfileController {
|
||||
}
|
||||
|
||||
@GetMapping("/queryivt1")
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备档案")
|
||||
public ResponseEntity<Object> queryivt1(@RequestParam Map whereJson){
|
||||
return new ResponseEntity<>(equipmentfileService.queryAll1(whereJson),HttpStatus.OK);
|
||||
}
|
||||
@GetMapping("/queryivt2")
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备档案")
|
||||
public ResponseEntity<Object> queryivt2(@RequestParam Map whereJson){
|
||||
return new ResponseEntity<>(equipmentfileService.queryAll2(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/queryivt3")
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备档案")
|
||||
public ResponseEntity<Object> queryivt3(@RequestParam Map whereJson){
|
||||
return new ResponseEntity<>(equipmentfileService.queryAll3(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/queryivt4")
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备档案")
|
||||
public ResponseEntity<Object> queryivt4(@RequestParam Map whereJson){
|
||||
return new ResponseEntity<>(equipmentfileService.queryAll4(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/queryivt5")
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备档案")
|
||||
public ResponseEntity<Object> queryivt5(@RequestParam Map whereJson){
|
||||
return new ResponseEntity<>(equipmentfileService.queryAll5(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/queryivt6")
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备档案")
|
||||
public ResponseEntity<Object> queryivt6(@RequestParam Map whereJson){
|
||||
return new ResponseEntity<>(equipmentfileService.queryAll6(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/queryivt7")
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备档案")
|
||||
public ResponseEntity<Object> queryivt7(@RequestParam Map whereJson){
|
||||
return new ResponseEntity<>(equipmentfileService.queryAll7(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/queryBomList")
|
||||
@ApiOperation("查询工令")
|
||||
@ApiOperation("查询设备档案")
|
||||
public ResponseEntity<Object> queryBomList(@RequestParam Map whereJson){
|
||||
return new ResponseEntity<>(equipmentfileService.queryBomList(whereJson),HttpStatus.OK);
|
||||
}
|
||||
@@ -140,4 +143,14 @@ public class EquipmentfileController {
|
||||
storateTab.update(param, "storage_id = '" + localStorage.getId() + "'");
|
||||
return new ResponseEntity(localStorage, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入bom数据
|
||||
*/
|
||||
@Log("导入设备档案")
|
||||
@PostMapping("/excelImport")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
RedissonUtils.lock(() -> equipmentfileService.excelImport(file, request), "导入设备档案", null);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ package org.nl.wms.masterdata_manage.em.service;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@@ -105,4 +108,11 @@ public interface EquipmentfileService {
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
JSONArray queryBomList(Map whereJson);
|
||||
|
||||
/**
|
||||
* 导入设备档案
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ package org.nl.wms.masterdata_manage.em.service.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -19,21 +21,28 @@ import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.masterdata_manage.em.service.EquipmentfileService;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.system_manage.service.dept.ISysDeptService;
|
||||
import org.nl.wms.system_manage.service.tableData.ColumnInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class EquipmentfileServiceImpl implements EquipmentfileService {
|
||||
|
||||
private final ClassstandardService classstandardService;
|
||||
@Autowired
|
||||
private ClassstandardService classstandardService;
|
||||
|
||||
@Autowired
|
||||
private ColumnInfoService columnInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
@@ -432,4 +441,51 @@ public class EquipmentfileServiceImpl implements EquipmentfileService {
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
try {
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
Map<String, String> tableColumn = columnInfoService.TableColumn2("em_bi_equipmentfile");
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
Map<Integer, String> IndexValue = new HashMap<>();
|
||||
for (int i = 0; i < read.get(0).size(); i++) {
|
||||
String label = String.valueOf(read.get(0).get(i));String value = tableColumn.get(label);
|
||||
if (value!=null){ IndexValue.put(i,value); }
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
JSONArray array = new JSONArray();
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (int i = 1; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
JSONObject item = new JSONObject();
|
||||
for (int i1 = 0; i1 < list.size(); i1++) {
|
||||
String s = IndexValue.get(i1);
|
||||
if (s!=null){
|
||||
item.put(s,list.get(i1));
|
||||
|
||||
}
|
||||
}
|
||||
item.put("create_id",currentUserId);
|
||||
item.put("create_name",currentUsername);
|
||||
item.put("create_time",now);
|
||||
array.add(item);
|
||||
ids.add(item.getString("devicerecord_id"));
|
||||
}
|
||||
System.out.println(array.size());
|
||||
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 工艺路线主表
|
||||
mstTab.delete("devicerecord_id in "+"('" + ids.stream().collect(Collectors.joining("','")) + "')");
|
||||
for (Object o : array) {
|
||||
mstTab.insert((JSONObject)o);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -11,9 +11,9 @@ import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtSectattrServic
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtStructattrService;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtSectattr;
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtStructattr;
|
||||
import org.nl.wms.masterdata_manage.备份master.service.MaterialbaseService;
|
||||
import org.nl.wms.masterdata_manage.备份master.service.dto.MaterialbaseDto;
|
||||
import org.nl.wms.masterdata_manage.备份master.service.impl.MaterialbaseServiceImpl;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.MaterialbaseService;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.dto.MaterialbaseDto;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.impl.MaterialbaseServiceImpl;
|
||||
import org.nl.wms.storage_manage.IOSEnum;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.iostorInv.dao.StIvtIostorinvdisYl;
|
||||
import org.nl.wms.storage_manage.rawmanage.service.iostorInv.dao.StIvtIostorinvdtlYl;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ColumnInfoService {
|
||||
private ColumnMapper columnMapper;
|
||||
|
||||
|
||||
Map<String,String> TableColumn(String tableName){
|
||||
public Map<String,String> TableColumn(String tableName){
|
||||
Map map = new HashMap<>();
|
||||
try {
|
||||
List<Map<String, String>> mapList = columnMapper.listTableColumn(tableName);
|
||||
@@ -41,6 +41,16 @@ public class ColumnInfoService {
|
||||
}
|
||||
return map;
|
||||
};
|
||||
public Map<String,String> TableColumn2(String tableName){
|
||||
Map map = new HashMap<>();
|
||||
try {
|
||||
List<Map<String, String>> mapList = columnMapper.listTableColumn(tableName);
|
||||
map = mapList.stream().collect(Collectors.toMap((Function<Map<String, String>, Object>) stringStringMap -> stringStringMap.get("COLUMN_COMMENT"), (Function<Map<String, String>, Object>) stringStringMap -> stringStringMap.get("COLUMN_NAME")));
|
||||
}catch (Exception ex){
|
||||
log.error(tableName+"获取表结构失败",ex);
|
||||
}
|
||||
return map;
|
||||
};
|
||||
|
||||
@SneakyThrows
|
||||
public <T> void exportFile(String tableName,List<Map> data, HttpServletResponse response,List passParam, Map<String,String> customizMap) {
|
||||
|
||||
@@ -12,7 +12,7 @@ spring:
|
||||
task:
|
||||
pool:
|
||||
# 核心线程池大小
|
||||
core-pool-size: 10pcsIfPurchaseorder/confirm
|
||||
core-pool-size: 10
|
||||
# 最大线程数
|
||||
max-pool-size: 30
|
||||
# 活跃时间
|
||||
|
||||
@@ -22,3 +22,7 @@ ALTER TABLE st_ivt_structivt_bcp
|
||||
-- CP移库类型
|
||||
INSERT INTO `hl_one_mes`.`sys_dict`(`dict_id`, `code`, `name`, `label`, `value`, `dict_sort`, `dict_type`, `para1`, `para2`, `para3`, `create_id`, `create_name`, `create_time`, `update_id`, `update_name`, `update_time`) VALUES ('1703954832731279360', 'ST_INV_CP_IN_TYPE', '成品入库单据类型', '移库入库', '0003', 3, NULL, NULL, NULL, NULL, '1694303357524643840', '管理员', '2023-09-19 10:11:04', '1694303357524643840', '管理员', '2023-09-19 10:11:04');
|
||||
INSERT INTO `hl_one_mes`.`sys_dict`(`dict_id`, `code`, `name`, `label`, `value`, `dict_sort`, `dict_type`, `para1`, `para2`, `para3`, `create_id`, `create_name`, `create_time`, `update_id`, `update_name`, `update_time`) VALUES ('1703955348920078336', 'ST_INV_CP_OUT_TYPE', '成品出库单据类型', '移库出库', '1003', 3, NULL, NULL, NULL, NULL, '1694303357524643840', '管理员', '2023-09-19 10:13:07', '1694303357524643840', '管理员', '2023-09-19 10:13:16');
|
||||
-- 设备档案新增字段
|
||||
ALTER TABLE em_bi_equipmentfile
|
||||
ADD COLUMN `power` varchar(64) COMMENT '功率',
|
||||
ADD COLUMN `plc_model` varchar(64) COMMENT 'plc型号';
|
||||
|
||||
Reference in New Issue
Block a user