保养工单-快速工单

highway
wws 1 year ago
parent 450ccdf163
commit 2c3f1996b9

@ -8,6 +8,7 @@ import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.device.domain.EquOrder;
import com.op.device.domain.EquPlan;
import com.op.device.service.IEquUpkeepOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -66,8 +67,8 @@ public class EquUpkeepOrderController extends BaseController {
@RequiresPermissions("device:upkeepOrder:add")
@Log(title = "保养工单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EquOrder equOrder) {
return toAjax(equUpkeepOrderService.insertEquOrder(equOrder));
public AjaxResult add(@RequestBody EquPlan equPlan) {
return equUpkeepOrderService.insertEquOrder(equPlan);
}
/**

@ -0,0 +1,182 @@
package com.op.device.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
/**
* equ_order_equ_spare
*
* @author Open Platform
* @date 2023-11-02
*/
public class EquOrderEquSpare extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
private String id;
/** 编码 */
@Excel(name = "编码")
private String code;
/** 主工单信息 */
@Excel(name = "主工单信息")
private String orderCode;
/** 关联上级code */
@Excel(name = "关联上级code")
private String parentCode;
/** 备件code */
@Excel(name = "备件code")
private String materialCode;
/** 备件名称 */
@Excel(name = "备件名称")
private String materialDesc;
/** 备件类型 */
@Excel(name = "备件类型")
private String spareType;
/** 申领数量 */
@Excel(name = "申领数量")
private BigDecimal applyNum;
/** 工厂 */
@Excel(name = "工厂")
private String factoryCode;
/** 备用字段1 */
@Excel(name = "备用字段1")
private String attr1;
/** 备用字段2 */
@Excel(name = "备用字段2")
private String attr2;
/** 备用字段3 */
@Excel(name = "备用字段3")
private String attr3;
/** 删除标识 */
private String delFlag;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setCode(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getOrderCode() {
return orderCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getParentCode() {
return parentCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialCode() {
return materialCode;
}
public void setMaterialDesc(String materialDesc) {
this.materialDesc = materialDesc;
}
public String getMaterialDesc() {
return materialDesc;
}
public void setSpareType(String spareType) {
this.spareType = spareType;
}
public String getSpareType() {
return spareType;
}
public void setApplyNum(BigDecimal applyNum) {
this.applyNum = applyNum;
}
public BigDecimal getApplyNum() {
return applyNum;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryCode() {
return factoryCode;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr1() {
return attr1;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getAttr2() {
return attr2;
}
public void setAttr3(String attr3) {
this.attr3 = attr3;
}
public String getAttr3() {
return attr3;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getDelFlag() {
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("code", getCode())
.append("orderCode", getOrderCode())
.append("parentCode", getParentCode())
.append("materialCode", getMaterialCode())
.append("materialDesc", getMaterialDesc())
.append("spareType", getSpareType())
.append("applyNum", getApplyNum())
.append("factoryCode", getFactoryCode())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -0,0 +1,61 @@
package com.op.device.mapper;
import java.util.List;
import com.op.device.domain.EquOrderEquSpare;
/**
* Mapper
*
* @author Open Platform
* @date 2023-11-02
*/
public interface EquOrderEquSpareMapper {
/**
*
*
* @param id
* @return
*/
public EquOrderEquSpare selectEquOrderEquSpareById(String id);
/**
*
*
* @param equOrderEquSpare
* @return
*/
public List<EquOrderEquSpare> selectEquOrderEquSpareList(EquOrderEquSpare equOrderEquSpare);
/**
*
*
* @param equOrderEquSpare
* @return
*/
public int insertEquOrderEquSpare(EquOrderEquSpare equOrderEquSpare);
/**
*
*
* @param equOrderEquSpare
* @return
*/
public int updateEquOrderEquSpare(EquOrderEquSpare equOrderEquSpare);
/**
*
*
* @param id
* @return
*/
public int deleteEquOrderEquSpareById(String id);
/**
*
*
* @param ids
* @return
*/
public int deleteEquOrderEquSpareByIds(String[] ids);
}

@ -92,4 +92,10 @@ public interface EquOrderMapper {
* @return
*/
EquOrder selectEquOrderByOrderId(String orderId);
/**
*
* @return
*/
int selectSerialNumber();
}

@ -1,6 +1,8 @@
package com.op.device.service;
import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.EquOrder;
import com.op.device.domain.EquPlan;
import java.util.List;
@ -33,7 +35,7 @@ public interface IEquUpkeepOrderService {
* @param equOrder
* @return
*/
public int insertEquOrder(EquOrder equOrder);
public AjaxResult insertEquOrder(EquPlan equPlan);
/**
*

@ -1,15 +1,26 @@
package com.op.device.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.utils.DateUtils;
import com.op.device.domain.EquOrder;
import com.op.device.mapper.EquOrderMapper;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.*;
import com.op.device.mapper.*;
import com.op.device.service.IEquUpkeepOrderService;
import com.op.system.api.domain.SysUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import static com.op.common.core.web.domain.AjaxResult.success;
/**
* Service
*
@ -20,6 +31,16 @@ import java.util.List;
public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
@Autowired
private EquOrderMapper equOrderMapper;
@Autowired
private EquOrderEquSpareMapper equOrderEquSpareMapper;
@Autowired
private EquOrderStandardMapper equOrderStandardMapper;
@Autowired
private EquOrderDetailMapper equOrderDetailMapper;
@Autowired
private EquOrderPersonMapper equOrderPersonMapper;
@Autowired
private EquOrderEquMapper equOrderEquMapper;
/**
*
@ -46,16 +67,136 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
}
/**
*
* TODO
*
* @param equOrder
* @param equPlan
* @return
*/
@Override
@DS("#header.poolName")
public int insertEquOrder(EquOrder equOrder) {
public AjaxResult insertEquOrder(EquPlan equPlan) {
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 生成主工单信息
EquOrder equOrder = new EquOrder();
BeanUtils.copyProperties(equPlan,equOrder);
equOrder.setOrderId(IdUtils.fastSimpleUUID());
// 流水号
String serialNum = String.format("%03d",equOrderMapper.selectSerialNumber());
equOrder.setOrderCode("F"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+serialNum);
equOrder.setPlanLoopType("");
equOrder.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equOrder.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
// 设置工单状态
equOrder.setOrderStatus("0");
equOrder.setFactoryCode(factory);
equOrder.setCreateBy(SecurityContextHolder.getUserName());
equOrder.setCreateTime(DateUtils.getNowDate());
return equOrderMapper.insertEquOrder(equOrder);
equOrder.setUpdateBy(SecurityContextHolder.getUserName());
equOrder.setUpdateTime(DateUtils.getNowDate());
equOrder.setPlanType("maintenance");
// 工单插入数据库
equOrderMapper.insertEquOrder(equOrder);
// 生成工单-设备
EquOrderEqu equ = new EquOrderEqu();
List<EquPlanEqu> equPlanEquList = equPlan.getEquipmentItem();
EquPlanEqu equPlanEqu = equPlanEquList.get(0);
BeanUtils.copyProperties(equPlanEqu,equ);
equ.setId(IdUtils.fastSimpleUUID());
equ.setCode("E"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+"001");
equ.setParentCode(equOrder.getOrderCode());
equ.setOrderCode(equOrder.getOrderCode());
equ.setFactoryCode(factory);
equ.setAttr1("");
equ.setCreateBy(SecurityContextHolder.getUserName());
// 设备插入
equOrderEquMapper.insertEquOrderEqu(equ);
// 生成工单-备件
List<EquOrderEquSpare> spareList = new ArrayList<>();
List<EquPlanEquSpare> equSpareList = equPlanEqu.getSpareList();
int spareSerialNum = 0;
for (EquPlanEquSpare spare : equSpareList) {
EquOrderEquSpare spareTemp = new EquOrderEquSpare();
BeanUtils.copyProperties(spare,spareTemp);
spareTemp.setId(IdUtils.fastSimpleUUID());
spareTemp.setCode("S"+equOrder.getOrderCode()+String.format("%03d",++spareSerialNum));
spareTemp.setOrderCode(equOrder.getOrderCode());
spareTemp.setParentCode(equ.getCode());
spareTemp.setFactoryCode(factory);
spareTemp.setCreateBy(SecurityContextHolder.getUserName());
spareTemp.setCreateTime(DateUtils.getNowDate());
spareTemp.setUpdateBy(SecurityContextHolder.getUserName());
spareTemp.setUpdateTime(DateUtils.getNowDate());
// 插入备件信息
equOrderEquSpareMapper.insertEquOrderEquSpare(spareTemp);
spareList.add(spareTemp);
}
// 备件置入
System.out.println(spareList);
// 生成工单-设备-保养项
List<EquPlanDetail> detailList = equPlanEqu.getEquPlanDetailList();
int detailSerialNum = 0;
for (EquPlanDetail detail : detailList) {
EquOrderDetail equOrderDetail = new EquOrderDetail();
List<EquOrderStandard> orderStandardList = new ArrayList<>();
List<EquPlanStandard> standardList = detail.getEquPlanStandardList();
BeanUtils.copyProperties(detail,equOrderDetail);
equOrderDetail.setId(IdUtils.fastSimpleUUID());
equOrderDetail.setCode("C"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+String.format("%03d",++detailSerialNum));
equOrderDetail.setOrderCode(equOrder.getOrderCode());
equOrderDetail.setParentCode(equ.getCode());
equOrderDetail.setFactroyCode(factory);
equOrderDetail.setStandardList(orderStandardList);
equOrderDetail.setCreateBy(SecurityContextHolder.getUserName());
equOrderDetail.setCreateTime(DateUtils.getNowDate());
equOrderDetail.setUpdateBy(SecurityContextHolder.getUserName());
equOrderDetail.setUpdateTime(DateUtils.getNowDate());
// 插入检查项信息
equOrderDetailMapper.insertEquOrderDetail(equOrderDetail);
int standardSerialNum = 0;
for (EquPlanStandard standard : standardList) {
EquOrderStandard orderStandard = new EquOrderStandard();
BeanUtils.copyProperties(standard,orderStandard);
orderStandard.setId(IdUtils.fastSimpleUUID());
orderStandard.setCode("S"+equOrder.getOrderCode()+String.format("%03d",++standardSerialNum));
orderStandard.setParentCode(equOrderDetail.getCode());
orderStandard.setOrderCode(equOrder.getOrderCode());
orderStandard.setCreateBy(SecurityContextHolder.getUserName());
orderStandard.setCreateTime(DateUtils.getNowDate());
orderStandard.setUpdateBy(SecurityContextHolder.getUserName());
orderStandard.setUpdateTime(DateUtils.getNowDate());
// 插入标准信息
equOrderStandardMapper.insertEquOrderStandard(orderStandard);
}
}
// 生成工单-人员
List<SysUser> personList = equPlan.getPersonList();
for (SysUser user : personList) {
EquOrderPerson equOrderPerson = new EquOrderPerson();
equOrderPerson.setId(IdUtils.fastSimpleUUID());
// TODO 要改变编码格式
equOrderPerson.setOrderCode(equOrder.getOrderCode());
equOrderPerson.setFactoryCode(factory);
equOrderPerson.setUserId(user.getUserId());
equOrderPerson.setCreateBy(SecurityContextHolder.getUserName());
equOrderPerson.setCreateTime(DateUtils.getNowDate());
equOrderPerson.setUpdateBy(SecurityContextHolder.getUserName());
equOrderPerson.setUpdateTime(DateUtils.getNowDate());
// 插入人员信息
equOrderPersonMapper.insertEquOrderPerson(equOrderPerson);
}
return success();
}
/**

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.device.mapper.EquOrderEquSpareMapper">
<resultMap type="EquOrderEquSpare" id="EquOrderEquSpareResult">
<result property="id" column="id" />
<result property="code" column="code" />
<result property="orderCode" column="order_code" />
<result property="parentCode" column="parent_code" />
<result property="materialCode" column="material_code" />
<result property="materialDesc" column="material_desc" />
<result property="spareType" column="spare_type" />
<result property="applyNum" column="apply_num" />
<result property="factoryCode" column="factory_code" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectEquOrderEquSpareVo">
select id, code, order_code, parent_code, material_code, material_desc, spare_type, apply_num, factory_code, attr1, attr2, attr3, del_flag, create_by, create_time, update_by, update_time from equ_order_equ_spare
</sql>
<select id="selectEquOrderEquSpareList" parameterType="EquOrderEquSpare" resultMap="EquOrderEquSpareResult">
<include refid="selectEquOrderEquSpareVo"/>
<where>
<if test="code != null and code != ''"> and code = #{code}</if>
<if test="orderCode != null and orderCode != ''"> and order_code = #{orderCode}</if>
<if test="parentCode != null and parentCode != ''"> and parent_code = #{parentCode}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="materialDesc != null and materialDesc != ''"> and material_desc = #{materialDesc}</if>
<if test="spareType != null and spareType != ''"> and spare_type = #{spareType}</if>
<if test="applyNum != null "> and apply_num = #{applyNum}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''"> and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''"> and attr3 = #{attr3}</if>
</where>
</select>
<select id="selectEquOrderEquSpareById" parameterType="String" resultMap="EquOrderEquSpareResult">
<include refid="selectEquOrderEquSpareVo"/>
where id = #{id}
</select>
<insert id="insertEquOrderEquSpare" parameterType="EquOrderEquSpare">
insert into equ_order_equ_spare
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="code != null">code,</if>
<if test="orderCode != null">order_code,</if>
<if test="parentCode != null">parent_code,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialDesc != null">material_desc,</if>
<if test="spareType != null">spare_type,</if>
<if test="applyNum != null">apply_num,</if>
<if test="factoryCode != null and factoryCode != ''">factory_code,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="code != null">#{code},</if>
<if test="orderCode != null">#{orderCode},</if>
<if test="parentCode != null">#{parentCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialDesc != null">#{materialDesc},</if>
<if test="spareType != null">#{spareType},</if>
<if test="applyNum != null">#{applyNum},</if>
<if test="factoryCode != null and factoryCode != ''">#{factoryCode},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateEquOrderEquSpare" parameterType="EquOrderEquSpare">
update equ_order_equ_spare
<trim prefix="SET" suffixOverrides=",">
<if test="code != null">code = #{code},</if>
<if test="orderCode != null">order_code = #{orderCode},</if>
<if test="parentCode != null">parent_code = #{parentCode},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialDesc != null">material_desc = #{materialDesc},</if>
<if test="spareType != null">spare_type = #{spareType},</if>
<if test="applyNum != null">apply_num = #{applyNum},</if>
<if test="factoryCode != null and factoryCode != ''">factory_code = #{factoryCode},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEquOrderEquSpareById" parameterType="String">
delete from equ_order_equ_spare where id = #{id}
</delete>
<delete id="deleteEquOrderEquSpareByIds" parameterType="String">
delete from equ_order_equ_spare where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -111,6 +111,12 @@
where order_id = #{orderId}
</select>
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(order_id)+1 AS serialNum
FROM equ_order
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time) and del_flag = '0'
</select>
<insert id="insertEquOrder" parameterType="EquOrder">
insert into equ_order
<trim prefix="(" suffix=")" suffixOverrides=",">

Loading…
Cancel
Save