This commit is contained in:
parent
ff80946f86
commit
1f8ff23fcb
|
|
@ -18,6 +18,9 @@ import com.bonus.material.back.mapper.BackChangeMapper;
|
||||||
import com.bonus.material.back.service.BackChangeService;
|
import com.bonus.material.back.service.BackChangeService;
|
||||||
import com.bonus.material.common.constants.TypeConstants;
|
import com.bonus.material.common.constants.TypeConstants;
|
||||||
import com.bonus.material.common.enums.TypeEnums;
|
import com.bonus.material.common.enums.TypeEnums;
|
||||||
|
import com.bonus.material.devchange.domain.CsDeviceInfo;
|
||||||
|
import com.bonus.material.repair.domain.ToBeRepair;
|
||||||
|
import com.bonus.material.repair.mapper.RepairMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -42,6 +45,9 @@ public class BackChangeServiceImpl implements BackChangeService {
|
||||||
@Resource
|
@Resource
|
||||||
private BackChangeMapper mapper;
|
private BackChangeMapper mapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RepairMapper repairMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ApprovalInstanceMapper instanceMapper;
|
private ApprovalInstanceMapper instanceMapper;
|
||||||
|
|
||||||
|
|
@ -403,6 +409,12 @@ public class BackChangeServiceImpl implements BackChangeService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(devDetailsList)) {
|
if (CollectionUtils.isNotEmpty(devDetailsList)) {
|
||||||
|
// 创建维修任务
|
||||||
|
String re = createRepairTask(devDetailsList);
|
||||||
|
if ("-1".equals(re)){
|
||||||
|
throw new RuntimeException("创建维修任务失败");
|
||||||
|
}
|
||||||
|
|
||||||
for (BackCsDeviceDetails csDeviceDetails : devDetailsList) {
|
for (BackCsDeviceDetails csDeviceDetails : devDetailsList) {
|
||||||
// 装备
|
// 装备
|
||||||
if ("1".equals(csDeviceDetails.getDevType())) {
|
if ("1".equals(csDeviceDetails.getDevType())) {
|
||||||
|
|
@ -466,4 +478,75 @@ public class BackChangeServiceImpl implements BackChangeService {
|
||||||
}
|
}
|
||||||
return AjaxResult.success("审核成功");
|
return AjaxResult.success("审核成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createRepairTask(List<BackCsDeviceDetails> devDetailsList){
|
||||||
|
try {
|
||||||
|
//在此处将需要维修的设备,生成一个维修单
|
||||||
|
List<ToBeRepair> toBeRepairList = new ArrayList<>();
|
||||||
|
for (BackCsDeviceDetails csDeviceDetails : devDetailsList){
|
||||||
|
if ("1".equals(csDeviceDetails.getIsRepair())){
|
||||||
|
ToBeRepair toBeRepair = new ToBeRepair();
|
||||||
|
toBeRepair.setCode(csDeviceDetails.getDevCode());
|
||||||
|
toBeRepair.setDevType(csDeviceDetails.getDevType());
|
||||||
|
toBeRepair.setRepairNum(csDeviceDetails.getRealNum());
|
||||||
|
toBeRepair.setTypeId(csDeviceDetails.getTypeId()+ "");
|
||||||
|
toBeRepairList.add(toBeRepair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//如果有需要维修的设备
|
||||||
|
if (toBeRepairList.size() > 0){
|
||||||
|
//创建维修任务
|
||||||
|
String userName = SecurityUtils.getLoginUser().getSysUser().getNickName();
|
||||||
|
Long changeId = addRepairTask(userName);
|
||||||
|
//保存明细
|
||||||
|
for (ToBeRepair toBeRepair : toBeRepairList){
|
||||||
|
toBeRepair.setChangeId(changeId);
|
||||||
|
toBeRepair.setCreateUser(userName);
|
||||||
|
repairMapper.addRepairData(toBeRepair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "1";
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return "-1";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建维修任务
|
||||||
|
*/
|
||||||
|
private Long addRepairTask(String username) throws Exception {
|
||||||
|
int maxOrder = repairMapper.getMonthMaxOrderByDate(
|
||||||
|
DateUtils.getCurrentYear(),
|
||||||
|
DateUtils.getCurrentMonth(),
|
||||||
|
TypeEnums.TM_TASK_REPAIR.getTaskTypeId()
|
||||||
|
);
|
||||||
|
String code = genderRepairTaskCode(maxOrder);
|
||||||
|
CsDeviceInfo deviceInfo = new CsDeviceInfo();
|
||||||
|
deviceInfo.setType("4");
|
||||||
|
deviceInfo.setCode(code);
|
||||||
|
deviceInfo.setReviewStatus("5");
|
||||||
|
deviceInfo.setCreateUser(username);
|
||||||
|
deviceInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
||||||
|
int result = repairMapper.addDeviceChange(deviceInfo);
|
||||||
|
if (result < 1) {
|
||||||
|
throw new Exception("添加任务失败");
|
||||||
|
}
|
||||||
|
return deviceInfo.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成维修任务编号
|
||||||
|
* @param thisMonthMaxOrder
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String genderRepairTaskCode(int thisMonthMaxOrder) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
|
String format = dateFormat.format(nowDate);
|
||||||
|
String result = format.replace("-", "");
|
||||||
|
return TypeConstants.REPAIR_TASK_TYPE_LABEL + result + String.format("-%04d", thisMonthMaxOrder + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,4 +147,7 @@ public class ToBeRepair {
|
||||||
|
|
||||||
@ApiModelProperty(value = "所属公司id")
|
@ApiModelProperty(value = "所属公司id")
|
||||||
private Long companyId;
|
private Long companyId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否是审核")
|
||||||
|
private int isAudit;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,4 +142,39 @@ public interface RepairMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int auditInfoById(ToBeRepair info);
|
int auditInfoById(ToBeRepair info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物理删除设备详情信息
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int physicalDeletionDetailsByChangeId(ToBeRepair bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新任务状态
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateStatusById(ToBeRepair bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备状态
|
||||||
|
* @param detail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateDevStatus(ToBeRepair detail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备详情信息
|
||||||
|
* @param detail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateToolStatus(ToBeRepair detail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备详情信息
|
||||||
|
* @param detail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateToolNum(ToBeRepair detail);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,33 @@ public class RepairServiceImpl implements RepairService {
|
||||||
}
|
}
|
||||||
String username = getCurrentUsername();
|
String username = getCurrentUsername();
|
||||||
|
|
||||||
// 1. 创建维修任务
|
Long changeId;
|
||||||
Long changeId = createRepairTask(username);
|
if (bean.getChangeId()==null){
|
||||||
|
// 1. 创建维修任务
|
||||||
|
changeId = createRepairTask(username);
|
||||||
|
//将申请的设备状态都改为维修
|
||||||
|
for (ToBeRepair detail : list){
|
||||||
|
if ("编码管理".equals(detail.getManageMode()) && !StringHelper.isNullOrEmptyString(detail.getCode())){
|
||||||
|
//1、如果是编码管理,将设备状态改为维修状态
|
||||||
|
if ("装备".equals(detail.getType())){
|
||||||
|
int re1 = mapper.updateDevStatus(detail);
|
||||||
|
} else if ("工具".equals(detail.getType())){
|
||||||
|
int re2 = mapper.updateToolStatus(detail);
|
||||||
|
}
|
||||||
|
} else if ("数量管理".equals(detail.getManageMode())){
|
||||||
|
//目前数量管理的设备都是工具
|
||||||
|
//将在库数量减掉增加维修数量
|
||||||
|
int re3 = mapper.updateToolNum(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//退料维修任务提交
|
||||||
|
changeId = bean.getChangeId();
|
||||||
|
//清除旧数据
|
||||||
|
int res = mapper.physicalDeletionDetailsByChangeId(bean);
|
||||||
|
//修改主表任务为待审核
|
||||||
|
int re = mapper.updateStatusById(bean);
|
||||||
|
}
|
||||||
// 2. 保存明细
|
// 2. 保存明细
|
||||||
for (ToBeRepair detail : list) {
|
for (ToBeRepair detail : list) {
|
||||||
processRepairDetail(detail, changeId, username);
|
processRepairDetail(detail, changeId, username);
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,33 @@
|
||||||
review_time=NOW()
|
review_time=NOW()
|
||||||
where id = #{changeId}
|
where id = #{changeId}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateStatusById">
|
||||||
|
update cs_device_change
|
||||||
|
set review_status = '0',
|
||||||
|
update_time = NOW()
|
||||||
|
where id = #{changeId}
|
||||||
|
</update>
|
||||||
|
<update id="updateDevStatus">
|
||||||
|
update ma_dev_info
|
||||||
|
set ma_status ='5'
|
||||||
|
where type_id = #{typeId}
|
||||||
|
and `code` = #{code}
|
||||||
|
</update>
|
||||||
|
<update id="updateToolStatus">
|
||||||
|
update tool_ledger
|
||||||
|
set status = '2'
|
||||||
|
where type_id = #{typeId}
|
||||||
|
and tool_code = #{code}
|
||||||
|
</update>
|
||||||
|
<update id="updateToolNum">
|
||||||
|
update tool_ledger
|
||||||
|
set available_num=available_num - #{repairNum},
|
||||||
|
repair_num=repair_num + #{repairNum}
|
||||||
|
where type_id = #{typeId}
|
||||||
|
</update>
|
||||||
|
<delete id="physicalDeletionDetailsByChangeId">
|
||||||
|
delete from cs_device_change_details where change_id = #{changeId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
<select id="selectToBeRepairList" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
<select id="selectToBeRepairList" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
||||||
SELECT
|
SELECT
|
||||||
|
|
@ -166,8 +193,8 @@
|
||||||
LEFT JOIN tool_type tt4 on tt4.type_id = tt5.parent_id
|
LEFT JOIN tool_type tt4 on tt4.type_id = tt5.parent_id
|
||||||
LEFT JOIN tool_type tt3 on tt3.type_id = tt4.parent_id
|
LEFT JOIN tool_type tt3 on tt3.type_id = tt4.parent_id
|
||||||
LEFT JOIN tool_type tt2 on tt2.type_id = tt3.parent_id
|
LEFT JOIN tool_type tt2 on tt2.type_id = tt3.parent_id
|
||||||
WHERE ((tl.manage_mode = '1' AND tl.repair_num IS NOT NULL AND tl.repair_num > 0)
|
WHERE ((tl.manage_mode = '1' AND tl.available_num IS NOT NULL AND tl.available_num > 0)
|
||||||
OR (tl.manage_mode = '0' AND tl.`status` = '2'))
|
OR (tl.manage_mode = '0' AND tl.`status` = '0'))
|
||||||
<if test="manageType != null and manageType!=''">
|
<if test="manageType != null and manageType!=''">
|
||||||
AND tl.manage_mode = #{manageType}
|
AND tl.manage_mode = #{manageType}
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -186,6 +213,7 @@
|
||||||
<if test='devType == "1"'>
|
<if test='devType == "1"'>
|
||||||
AND 1=0
|
AND 1=0
|
||||||
</if>
|
</if>
|
||||||
|
HAVING tobeRepairNum > 0
|
||||||
|
|
||||||
UNION
|
UNION
|
||||||
|
|
||||||
|
|
@ -206,7 +234,7 @@
|
||||||
LEFT JOIN ma_type mt4 on mt4.type_id = mt5.parent_id
|
LEFT JOIN ma_type mt4 on mt4.type_id = mt5.parent_id
|
||||||
LEFT JOIN ma_type mt3 on mt3.type_id = mt4.parent_id
|
LEFT JOIN ma_type mt3 on mt3.type_id = mt4.parent_id
|
||||||
LEFT JOIN ma_type mt2 on mt2.type_id = mt3.parent_id
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt3.parent_id
|
||||||
WHERE mdi.ma_status = '5'
|
WHERE mdi.ma_status = '1'
|
||||||
<if test="typeName != null and typeName!=''">
|
<if test="typeName != null and typeName!=''">
|
||||||
AND mdi.device_name like concat('%',#{typeName},'%')
|
AND mdi.device_name like concat('%',#{typeName},'%')
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -260,6 +288,9 @@
|
||||||
<if test="companyId != null">
|
<if test="companyId != null">
|
||||||
and cdc.company_id = #{companyId}
|
and cdc.company_id = #{companyId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="isAudit==1">
|
||||||
|
and cdc.review_status !='5'
|
||||||
|
</if>
|
||||||
GROUP BY cdc.id
|
GROUP BY cdc.id
|
||||||
ORDER BY cdc.create_time DESC
|
ORDER BY cdc.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue