设备与工单基础CRUD
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package org.nl.wms.enums;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 工单枚举
|
||||
* @Date: 2023/3/16
|
||||
*/
|
||||
public enum WorkerOrderEnum {
|
||||
// 1-创建、2-下发、3-生产中、4-暂停、5-完成
|
||||
CREATE("创建", "1"),
|
||||
SEND("下发", "2"),
|
||||
PRODUCTING("生产中", "3"),
|
||||
STOP("暂停", "4"),
|
||||
COMPLETE("完成", "5"),
|
||||
// 1-PC创建、2-Excel导入
|
||||
PCINTO("PC创建", "1"),
|
||||
EXCELINTO("EXCEL导入", "2"),
|
||||
// 1白班、2夜班
|
||||
DAYSHIFT("白班", "1"),
|
||||
NIGHTSHIFT("夜班", "2")
|
||||
;
|
||||
|
||||
|
||||
private String name;
|
||||
private String code;
|
||||
|
||||
WorkerOrderEnum(String name, String code) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package org.nl.wms.mps.rest;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.wms.mps.service.ProduceWorkorderService;
|
||||
import org.nl.wms.mps.service.dto.ProduceWorkorderDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-03-16
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "工单管理管理")
|
||||
@RequestMapping("/api/produceWorkorder")
|
||||
@Slf4j
|
||||
public class ProduceWorkorderController {
|
||||
|
||||
private final ProduceWorkorderService produceWorkorderService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询工单管理")
|
||||
@ApiOperation("查询工单管理")
|
||||
//@PreAuthorize("@el.check('produceWorkorder:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(produceWorkorderService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增工单管理")
|
||||
@ApiOperation("新增工单管理")
|
||||
//@PreAuthorize("@el.check('produceWorkorder:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody ProduceWorkorderDto dto) {
|
||||
produceWorkorderService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改工单管理")
|
||||
@ApiOperation("修改工单管理")
|
||||
//@PreAuthorize("@el.check('produceWorkorder:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody ProduceWorkorderDto dto) {
|
||||
produceWorkorderService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除工单管理")
|
||||
@ApiOperation("删除工单管理")
|
||||
//@PreAuthorize("@el.check('produceWorkorder:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
produceWorkorderService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getNotWorkDeviceByWorkproceduceId")
|
||||
@Log("根据工序查询没有工单的设备")
|
||||
@ApiOperation("根据工序查询没有工单的设备")
|
||||
//@PreAuthorize("@el.check('WorkProcedure:add')")
|
||||
public ResponseEntity<Object> getNotWorkDeviceByWorkproceduceId(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(produceWorkorderService.getNotWorkDeviceByWorkproceduceId(param),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/getDtl")
|
||||
@Log("获取当前工单下的工单生产记录")
|
||||
@ApiOperation("获取当前工单下的工单生产记录")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> getDtl(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(produceWorkorderService.getDtl(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/forceFinish")
|
||||
@Log("工单强制完成")
|
||||
@ApiOperation("工单强制完成")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> forceFinish(@RequestBody JSONObject param) {
|
||||
produceWorkorderService.forceFinish(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/excelImport")
|
||||
@Log("excel导入")
|
||||
@ApiOperation("excel导入")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
produceWorkorderService.excelImport(file, request);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
|
||||
package org.nl.wms.mps.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.mps.service.dto.ProduceWorkorderDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description 服务接口
|
||||
* @author lyd
|
||||
* @date 2023-03-16
|
||||
**/
|
||||
public interface ProduceWorkorderService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param whereJson 条件参数
|
||||
* @return List<ProduceWorkorderDto>
|
||||
*/
|
||||
List<ProduceWorkorderDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param workorder_id ID
|
||||
* @return ProduceWorkorder
|
||||
*/
|
||||
ProduceWorkorderDto findById(String workorder_id);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
* @param code code
|
||||
* @return ProduceWorkorder
|
||||
*/
|
||||
ProduceWorkorderDto findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param dto /
|
||||
*/
|
||||
void create(ProduceWorkorderDto dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param dto /
|
||||
*/
|
||||
void update(ProduceWorkorderDto dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(String[] ids);
|
||||
|
||||
/**
|
||||
* 更换设备时根据工单所属工序 查询所有工单中没有生产的设备
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
JSONArray getNotWorkDeviceByWorkproceduceId(JSONObject param);
|
||||
|
||||
/**
|
||||
* 获取当前工单的记录
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
JSONArray getDtl(JSONObject param);
|
||||
|
||||
/**
|
||||
* 强制完成
|
||||
* @param param
|
||||
*/
|
||||
void forceFinish(JSONObject param);
|
||||
|
||||
/**
|
||||
* 看板强制完成
|
||||
* @param param
|
||||
*/
|
||||
void finish(JSONObject param);
|
||||
|
||||
/**
|
||||
* excel导入
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package org.nl.wms.mps.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @description /
|
||||
* @date 2023-03-16
|
||||
**/
|
||||
@Data
|
||||
public class ProduceWorkorderDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 工单编号
|
||||
*/
|
||||
private String workorder_id;
|
||||
|
||||
/**
|
||||
* 工单编号
|
||||
*/
|
||||
private String workorder_code;
|
||||
|
||||
/**
|
||||
* 班次类型
|
||||
*/
|
||||
private String shift_type_scode;
|
||||
|
||||
/**
|
||||
* 工序编码
|
||||
*/
|
||||
private String workprocedure_id;
|
||||
|
||||
/**
|
||||
* 生产区域
|
||||
*/
|
||||
private String product_area;
|
||||
|
||||
/**
|
||||
* 计划数量
|
||||
*/
|
||||
private BigDecimal plan_qty;
|
||||
|
||||
/**
|
||||
* 实际数量
|
||||
*/
|
||||
private BigDecimal real_qty;
|
||||
|
||||
/**
|
||||
* 人员实际数量
|
||||
*/
|
||||
private BigDecimal person_real_qty;
|
||||
|
||||
/**
|
||||
* 电气实际数量
|
||||
*/
|
||||
private BigDecimal dq_real_qty;
|
||||
|
||||
/**
|
||||
* 物料标识
|
||||
*/
|
||||
private String material_id;
|
||||
|
||||
/**
|
||||
* 物料单重
|
||||
*/
|
||||
private BigDecimal material_weight;
|
||||
|
||||
/**
|
||||
* 计划生产开始时间
|
||||
*/
|
||||
private String planproducestart_date;
|
||||
|
||||
/**
|
||||
* 计划生产结束时间
|
||||
*/
|
||||
private String planproduceend_date;
|
||||
|
||||
/**
|
||||
* 实际生产开始时间
|
||||
*/
|
||||
private String realproducestart_date;
|
||||
|
||||
/**
|
||||
* 实际生产结束时间
|
||||
*/
|
||||
private String realproduceend_date;
|
||||
|
||||
/**
|
||||
* 当前生产设备编码
|
||||
*/
|
||||
private String current_device_code;
|
||||
|
||||
/**
|
||||
* 当前生产人员id
|
||||
*/
|
||||
private String current_produce_person_id;
|
||||
|
||||
/**
|
||||
* 操作工是否允许修改报工数量
|
||||
*/
|
||||
private String is_canupdate_update;
|
||||
|
||||
/**
|
||||
* 工单状态
|
||||
*/
|
||||
private String workorder_status;
|
||||
|
||||
/**
|
||||
* 是否搬运
|
||||
*/
|
||||
private String is_needmove;
|
||||
|
||||
/**
|
||||
* 销售单标识
|
||||
*/
|
||||
private String sale_id;
|
||||
|
||||
/**
|
||||
* 创建类型
|
||||
*/
|
||||
private String create_type;
|
||||
|
||||
/**
|
||||
* 工单是否异常
|
||||
*/
|
||||
private String is_error;
|
||||
|
||||
/**
|
||||
* 异常信息
|
||||
*/
|
||||
private String error_info;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_id;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_id;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_name;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private String is_delete;
|
||||
}
|
||||
@@ -0,0 +1,557 @@
|
||||
|
||||
package org.nl.wms.mps.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
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;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
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.system.service.user.ISysUserService;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.wms.basedata.master.service.ClassstandardService;
|
||||
import org.nl.wms.enums.WorkerOrderEnum;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.mps.service.ProduceWorkorderService;
|
||||
import org.nl.wms.mps.service.WorkOrderImportEnum;
|
||||
import org.nl.wms.mps.service.dto.ProduceWorkorderDto;
|
||||
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 java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @description 服务实现
|
||||
* @date 2023-03-16
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ProduceWorkorderServiceImpl implements ProduceWorkorderService {
|
||||
|
||||
private final ClassstandardService classstandardService;
|
||||
|
||||
private final WmsToAcsService wmsToAcsService;
|
||||
|
||||
private final ISysUserService userService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String produceorder_code = MapUtil.getStr(whereJson, "produceorder_code");
|
||||
String material = MapUtil.getStr(whereJson, "material");
|
||||
String begin_time = MapUtil.getStr(whereJson, "begin_time");
|
||||
String end_time = MapUtil.getStr(whereJson, "end_time");
|
||||
String order_status = MapUtil.getStr(whereJson, "order_status");
|
||||
String shift_type_scode = MapUtil.getStr(whereJson, "shift_type_scode");
|
||||
String parent_id = MapUtil.getStr(whereJson, "product_series");
|
||||
String sale_id = MapUtil.getStr(whereJson, "sale_id");
|
||||
String is_error = MapUtil.getStr(whereJson, "is_error");
|
||||
String product_series = "";
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "1");
|
||||
//map.put("order_status", order_status);
|
||||
map.put("shift_type_scode", shift_type_scode);
|
||||
map.put("begin_time", begin_time);
|
||||
map.put("end_time", end_time);
|
||||
if (StrUtil.isNotEmpty(order_status)) {
|
||||
order_status = order_status.replace("[\"", "").replace("\"]", "").replace("\"", "");
|
||||
}
|
||||
map.put("order_status", order_status);
|
||||
map.put("is_error", is_error);
|
||||
//处理状态为未完成
|
||||
if (StrUtil.isNotEmpty(order_status) && order_status.contains("-1")) {
|
||||
map.put("unFinish", "-1");
|
||||
map.put("order_status", order_status.replace("-1", ""));
|
||||
}
|
||||
if (StrUtil.isNotEmpty(parent_id)) {
|
||||
product_series = classstandardService.getChildIdStr(parent_id);
|
||||
map.put("product_series", product_series);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(produceorder_code)) {
|
||||
map.put("produceorder_code", "%" + produceorder_code + "%");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(material)) {
|
||||
map.put("material", "%" + material + "%");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(sale_id)) {
|
||||
map.put("sale_id", "%" + sale_id + "%");
|
||||
}
|
||||
JSONObject jsonObject = WQL.getWO("MPS_PRODUCEWORKORDER").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "ShiftOrder.update_time desc");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProduceWorkorderDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(ProduceWorkorderDto.class);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProduceWorkorderDto findById(String workorder_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
JSONObject json = wo.query("workorder_id = '" + workorder_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(ProduceWorkorderDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProduceWorkorderDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(ProduceWorkorderDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(ProduceWorkorderDto dto) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
dto.setWorkorder_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_name(nickName);
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
dto.setCreate_time(DateUtil.now());
|
||||
dto.setWorkorder_id(IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
dto.setWorkorder_code(CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
dto.setCreate_type(WorkerOrderEnum.PCINTO.getCode());
|
||||
dto.setWorkorder_status(WorkerOrderEnum.CREATE.getCode());
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.insert(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(ProduceWorkorderDto dto) {
|
||||
ProduceWorkorderDto entity = this.findById(dto.getWorkorder_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_name(nickName);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.update(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(String[] ids) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
for (String workorder_id : ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("workorder_id", String.valueOf(workorder_id));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", DateUtil.now());
|
||||
wo.update(param);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getNotWorkDeviceByWorkproceduceId(JSONObject param) {
|
||||
Map res = new HashMap();
|
||||
res.put("flag", "2");
|
||||
res.put("workprocedure_id", param.getString("workproceduce_id"));
|
||||
JSONArray resultJSONArray = WQL.getWO("MPS_PRODUCEWORKORDER").addParamMap(res).process().getResultJSONArray(0);
|
||||
return resultJSONArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDtl(JSONObject param) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "3");
|
||||
map.put("workorder_id", param.getString("workorder_id"));
|
||||
JSONArray resultJSONArray = WQL.getWO("MPS_PRODUCEWORKORDER").addParamMap(map).process().getResultJSONArray(0);
|
||||
return resultJSONArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void forceFinish(JSONObject param) {
|
||||
this.finish(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(JSONObject param) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
JSONObject row = param.getJSONObject("row");
|
||||
//强制完成时修改工单状态
|
||||
String workorder_id = row.getString("workorder_id");
|
||||
WQLObject wo = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
ProduceWorkorderDto workorderDto = this.findById(workorder_id);
|
||||
JSONObject produceorderMap = new JSONObject();
|
||||
produceorderMap.put("workorder_id", workorder_id);
|
||||
produceorderMap.put("workorder_status", WorkerOrderEnum.COMPLETE.getCode());
|
||||
produceorderMap.put("update_id", currentUserId);
|
||||
produceorderMap.put("device_code", null);
|
||||
produceorderMap.put("update_name", nickName);
|
||||
produceorderMap.put("update_time", DateUtil.now());
|
||||
produceorderMap.put("realproduceend_date", DateUtil.now());
|
||||
wo.update(produceorderMap);
|
||||
JSONObject jsonObject = wo.query("workorder_id = '" + workorder_id + "'").uniqueResult(0);
|
||||
String real_qty = jsonObject.getString("real_qty");
|
||||
if (StrUtil.isEmpty(real_qty)) {
|
||||
real_qty = "0";
|
||||
}
|
||||
//同时修改工单记录表中的期末数量及完成数量
|
||||
WQLObject wo_record = WQLObject.getWQLObject("PDM_produce_workOrderRecord");
|
||||
JSONObject result = wo_record.query("workorder_id = '" + workorder_id + "' and (operatetime_end = '' or operatetime_end is null) ").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
// todo: 数量不明确
|
||||
result.put("person_finish_qty", real_qty);
|
||||
result.put("person_report_qty", real_qty);
|
||||
result.put("operatetime_end", DateUtil.now());
|
||||
wo_record.update(result);
|
||||
}
|
||||
//工单开工以后需要向acs强制完成 wms向acs发送请求 工单强制完成
|
||||
// TODO: 业务不明
|
||||
String order_status = workorderDto.getWorkorder_status();
|
||||
if (!order_status.equals("1") && !order_status.equals("2")) {
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("ext_order_id", workorder_id);
|
||||
map.put("type", "3");
|
||||
array.add(map);
|
||||
wmsToAcsService.orderStatusUpdate(array);
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//工单表
|
||||
WQLObject wo_order = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
//物料表
|
||||
WQLObject wo_material = WQLObject.getWQLObject("md_me_materialbase");
|
||||
//设备表
|
||||
WQLObject wo_device = WQLObject.getWQLObject("pdm_bi_device");
|
||||
//工序表
|
||||
WQLObject wo_workprocedure = WQLObject.getWQLObject("pdm_bi_workprocedure");
|
||||
//人员表
|
||||
//WQLObject wo_user = WQLObject.getWQLObject("sys_user");
|
||||
|
||||
// 调用用 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 = "";
|
||||
// 循环获取的数据
|
||||
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.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", WorkerOrderEnum.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 + "物料规格为空,";
|
||||
}
|
||||
JSONObject json_material = wo_material.query("is_delete = '0' and material_spec = '" + col + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json_material)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "物料规格对应物料信息不存在,";
|
||||
}else {
|
||||
param.put("material_id", json_material.getString("material_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");
|
||||
JSONObject json_device = wo_device.query("is_delete = '0' and device_code = '" + col + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json_device)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "设备编码不存在,";
|
||||
}
|
||||
if (!workprocedure_id.equals(json_device.getString("workprocedure_id"))) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "设备与所属工序不匹配,";
|
||||
}else {
|
||||
param.put("device_id", json_device.getString("device_id"));
|
||||
}
|
||||
}
|
||||
if (j == 11) {
|
||||
SysUser jsonUser = userService.getOne(new QueryWrapper<SysUser>().eq("username", SecurityUtils.getCurrentUsername()));
|
||||
if (ObjectUtil.isEmpty(jsonUser)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "生产人员编码不存在!";
|
||||
}else {
|
||||
param.put("jockey_id", jsonUser.getUserId());
|
||||
}
|
||||
}
|
||||
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("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());
|
||||
wo_order.insert(param);
|
||||
}
|
||||
|
||||
// 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("produceorder_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
param.put("produceorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
param.put("producedeviceorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
param.put("order_status", "00");
|
||||
param.put("order_type_scode", "01");
|
||||
param.put("produce_date", produce_date);
|
||||
param.put("shift_type_scode", "02");
|
||||
//循环每一行
|
||||
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 + "物料规格为空,";
|
||||
}
|
||||
JSONObject json_material = wo_material.query("is_delete = '0' and material_spec = '" + col + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json_material)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "物料规格对应物料信息不存在,";
|
||||
}else {
|
||||
param.put("material_id", json_material.getString("material_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");
|
||||
JSONObject json_device = wo_device.query("is_delete = '0' and device_code = '" + col + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json_device)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "设备编码不存在,";
|
||||
}
|
||||
if (!workprocedure_id.equals(json_device.getString("workprocedure_id"))) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "设备与所属工序不匹配,";
|
||||
}else {
|
||||
param.put("device_id", json_device.getString("device_id"));
|
||||
}
|
||||
}
|
||||
if (j == 11) {
|
||||
SysUser jsonUser = userService.getOne(new QueryWrapper<SysUser>().eq("username", SecurityUtils.getCurrentUsername()));
|
||||
if (ObjectUtil.isEmpty(jsonUser)) {
|
||||
is_error = "1";
|
||||
error_message = error_message + "生产人员编码不存在!";
|
||||
}else {
|
||||
param.put("jockey_id", jsonUser.getUserId());
|
||||
}
|
||||
}
|
||||
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("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());
|
||||
wo_order.insert(param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
[交易说明]
|
||||
交易名: 工单分页查询
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.jockey_id TYPEAS s_string
|
||||
输入.sale_id TYPEAS s_string
|
||||
输入.produceorder_id TYPEAS s_string
|
||||
输入.workprocedure_code TYPEAS s_string
|
||||
输入.order_status TYPEAS s_string
|
||||
输入.shift_type_scode TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
输入.produceorder_code TYPEAS s_string
|
||||
输入.material TYPEAS s_string
|
||||
输入.is_error TYPEAS s_string
|
||||
输入.product_series TYPEAS f_string
|
||||
输入.workprocedure_ids TYPEAS f_string
|
||||
输入.workprocedure_id TYPEAS f_string
|
||||
输入.unFinish TYPEAS s_string
|
||||
输入.device_ids TYPEAS f_string
|
||||
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
ShiftOrder.*,
|
||||
material.material_name,
|
||||
material.material_code,
|
||||
material.material_spec,
|
||||
pro.workprocedure_code,
|
||||
pro.workprocedure_name,
|
||||
user.person_name
|
||||
FROM
|
||||
PDM_produce_workOrder ShiftOrder
|
||||
left join md_me_materialbase material on material.material_id = ShiftOrder.material_id
|
||||
left join PDM_BI_WorkProcedure pro on pro.workprocedure_id = ShiftOrder.workprocedure_id
|
||||
left join sys_user user on user.user_id = ShiftOrder.current_produce_person_id
|
||||
WHERE
|
||||
ShiftOrder.is_delete = '0'
|
||||
OPTION 输入.unFinish <> ""
|
||||
ShiftOrder.workorder_status <> '5'
|
||||
ENDOPTION
|
||||
OPTION 输入.order_status <> ""
|
||||
find_in_set( ShiftOrder.workorder_status, 输入.order_status)
|
||||
ENDOPTION
|
||||
OPTION 输入.shift_type_scode <> ""
|
||||
ShiftOrder.shift_type_scode = 输入.shift_type_scode
|
||||
ENDOPTION
|
||||
OPTION 输入.is_error <> ""
|
||||
ShiftOrder.is_error = 输入.is_error
|
||||
ENDOPTION
|
||||
OPTION 输入.product_series <> ""
|
||||
material.product_series in 输入.product_series
|
||||
ENDOPTION
|
||||
OPTION 输入.begin_time <> ""
|
||||
ShiftOrder.produce_date >= 输入.begin_time
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
ShiftOrder.produce_date <= 输入.end_time
|
||||
ENDOPTION
|
||||
OPTION 输入.sale_id <> ""
|
||||
ShiftOrder.sale_id like 输入.sale_id
|
||||
ENDOPTION
|
||||
OPTION 输入.workprocedure_code <> ""
|
||||
ShiftOrder.workprocedure_code like 输入.workprocedure_code
|
||||
ENDOPTION
|
||||
OPTION 输入.material <> ""
|
||||
(
|
||||
material.material_code like 输入.material or
|
||||
material.material_name like 输入.material or
|
||||
material.material_spec like 输入.material
|
||||
)
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
IF 输入.flag = "2"
|
||||
QUERY
|
||||
SELECT
|
||||
device.*
|
||||
FROM
|
||||
pdm_bi_device device
|
||||
WHERE
|
||||
device.is_delete = '0'
|
||||
OPTION 输入.workprocedure_id <> ""
|
||||
device.workprocedure_id = 输入.workprocedure_id
|
||||
and device.device_code not in (
|
||||
select o.current_device_code as device_code
|
||||
from PDM_produce_workOrder o
|
||||
where o.workorder_status <> '5'
|
||||
)
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
record.*,
|
||||
device.device_code,
|
||||
device.device_name
|
||||
FROM
|
||||
PDM_produce_workOrderRecord record
|
||||
LEFT JOIN PDM_BI_Device device ON record.device_code = device.device_code
|
||||
WHERE
|
||||
1 = 1
|
||||
OPTION 输入.workorder_id <> ""
|
||||
record.workorder_id = 输入.workorder_id
|
||||
ENDOPTION
|
||||
order by record.seq_number
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
Binary file not shown.
Reference in New Issue
Block a user