Compare commits

...

4 Commits

12 changed files with 147 additions and 67 deletions

View File

@ -220,6 +220,7 @@ public class BackApplyController extends BaseController {
} }
for (BackApplyInfo backApplyInfo : record.getBackApplyDetails()) { for (BackApplyInfo backApplyInfo : record.getBackApplyDetails()) {
backApplyInfo.setParentId(record.getParentId()); backApplyInfo.setParentId(record.getParentId());
backApplyService.updateBackInfo(record.getParentId(),record.getCompanyId());
boolean re = backApplyService.upload(backApplyInfo) > 0; boolean re = backApplyService.upload(backApplyInfo) > 0;
if (!re) { if (!re) {
return AjaxResult.error("退料任务明细插入失败"); return AjaxResult.error("退料任务明细插入失败");

View File

@ -5,6 +5,7 @@ import com.bonus.sgzb.app.domain.BmAgreementInfo;
import com.bonus.sgzb.app.domain.MachinePart; import com.bonus.sgzb.app.domain.MachinePart;
import com.bonus.sgzb.app.domain.TmTask; import com.bonus.sgzb.app.domain.TmTask;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -41,11 +42,13 @@ public interface BackApplyAppMapper {
int del(BackApplyInfo record); int del(BackApplyInfo record);
List<BackApplyInfo> examineList(BackApplyInfo record); List<BackApplyInfo> examineList(BackApplyInfo record);
List<BackApplyInfo> examineListByUser(BackApplyInfo record); List<BackApplyInfo> examineListByUser(BackApplyInfo record);
List<BackApplyInfo> examineView(BackApplyInfo record); List<BackApplyInfo> examineView(BackApplyInfo record);
int audit(BackApplyInfo record); int audit(BackApplyInfo record);
int updateBackApply(BackApplyInfo record); int updateBackApply(BackApplyInfo record);
List<BackApplyInfo> selectBackApplyInfo(BackApplyInfo record); List<BackApplyInfo> selectBackApplyInfo(BackApplyInfo record);
@ -57,4 +60,6 @@ public interface BackApplyAppMapper {
List<TmTask> getMaTypeDetails(BackApplyInfo backApplyInfo); List<TmTask> getMaTypeDetails(BackApplyInfo backApplyInfo);
MachinePart getMachineParts(TmTask typeId); MachinePart getMachineParts(TmTask typeId);
void updateBackInfo(@Param("parentId") Integer parentId,@Param("companyId") String companyId);
} }

View File

@ -112,4 +112,6 @@ public interface BackApplyService {
* @return int * @return int
*/ */
int refuse(BackApplyInfo record); int refuse(BackApplyInfo record);
void updateBackInfo(Integer parentId,String companyId);
} }

View File

@ -205,4 +205,9 @@ public class BackApplyServiceImpl implements BackApplyService {
return 0; return 0;
} }
@Override
public void updateBackInfo(Integer parentId,String companyId) {
backApplyMapper.updateBackInfo(parentId,companyId);
}
} }

View File

@ -215,22 +215,8 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
// 插入领料出库明细表lease_out_details // 插入领料出库明细表lease_out_details
res = leaseOutDetailsMapper.insertSelective(record); res = leaseOutDetailsMapper.insertSelective(record);
if (res > 0) { if (res > 0) {
if (record.getManageType() == 2) {
// 成套机具减少 (ma_type 设备规格表)的库存数量
res = leaseOutDetailsMapper.updateMaTypeStockNum(record);
// 成套机具减少 (ma_type 设备规格表)配件的库存数量
List<TmTask> typeIds = leaseOutDetailsMapper.getMaTypeDetails(record);
typeIds.removeIf(item -> item == null);
for (TmTask typeId : typeIds) {
MachinePart machinePart = leaseOutDetailsMapper.getMachineParts(typeId);
machinePart.setPartNum((typeId.getPartNum() * record.getOutNum()));
typeId.setNum(machinePart.getNum() - machinePart.getPartNum());
res = leaseOutDetailsMapper.updateMaTypeStockNumCt(typeId);
}
} else {
// 普通机具减少 (ma_type 设备规格表)的库存数量 // 普通机具减少 (ma_type 设备规格表)的库存数量
res = leaseOutDetailsMapper.updateMaTypeStockNum(record); res = leaseOutDetailsMapper.updateMaTypeStockNum(record);
}
// 更新 (ma_machine 设备表)的状态 // 更新 (ma_machine 设备表)的状态
leaseOutDetailsMapper.updateMaMachineStatus(record); leaseOutDetailsMapper.updateMaMachineStatus(record);
} }

View File

@ -153,6 +153,12 @@ public class RepairTask {
/** 驳回原因 */ /** 驳回原因 */
private String remark; private String remark;
/** 待修状态为已完成的typeId */
private String typeId;
/** 待修状态为已完成的typeId */
private String typeIds;
/** 待修状态为已完成的maId */
private String maId;
/** 0未提交 1已提交 */ /** 0未提交 1已提交 */
private Integer commit; private Integer commit;
} }

View File

@ -56,6 +56,8 @@ public class RepairTaskDetails {
*/ */
@ApiModelProperty(value = "维修报废数量") @ApiModelProperty(value = "维修报废数量")
private int scrapNum; private int scrapNum;
@ApiModelProperty(value = "是否提交0未提交 1已提交")
private Integer commit;
/** /**
* 待修状态 * 待修状态
*/ */

View File

@ -1,13 +1,16 @@
package com.bonus.sgzb.base.mapper; package com.bonus.sgzb.base.mapper;
import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.base.domain.RepairApplyRecord; import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairPartDetails; import com.bonus.sgzb.base.domain.RepairPartDetails;
import com.bonus.sgzb.base.domain.RepairTask; import com.bonus.sgzb.base.domain.RepairTask;
import com.bonus.sgzb.base.domain.RepairTaskDetails; import com.bonus.sgzb.base.domain.RepairTaskDetails;
import com.bonus.sgzb.base.domain.vo.DictVo; import com.bonus.sgzb.base.domain.vo.DictVo;
import com.bonus.sgzb.system.api.domain.SysUser; import com.bonus.sgzb.system.api.domain.SysUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectKey;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -130,7 +133,7 @@ public interface RepairMapper {
* @param task * @param task
* @return * @return
*/ */
int getUnFinish(RepairTask task); int getUnFinish(RepairTaskDetails task);
/** /**
* 根据value获取字典数据 * 根据value获取字典数据
@ -163,4 +166,8 @@ public interface RepairMapper {
int addRepairCost(@Param("bean") RepairApplyRecord bean, @Param("costs") BigDecimal costs,@Param("partType") String partType); int addRepairCost(@Param("bean") RepairApplyRecord bean, @Param("costs") BigDecimal costs,@Param("partType") String partType);
List<RepairTask> getRepairTaskListByOne(RepairTask bean); List<RepairTask> getRepairTaskListByOne(RepairTask bean);
List<RepairTaskDetails> getRepairMaTypeId(RepairTask repairTask);
int updateCommit(RepairTask task);
} }

View File

@ -1,5 +1,6 @@
package com.bonus.sgzb.base.service.impl; package com.bonus.sgzb.base.service.impl;
import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.base.domain.RepairApplyRecord; import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairPartDetails; import com.bonus.sgzb.base.domain.RepairPartDetails;
import com.bonus.sgzb.base.domain.RepairTask; import com.bonus.sgzb.base.domain.RepairTask;
@ -22,6 +23,7 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* @author c liu * @author c liu
@ -67,8 +69,6 @@ public class RepairServiceImpl implements RepairService {
@Override @Override
public List<RepairTaskDetails> getRepairMaTypeList(RepairTaskDetails bean) { public List<RepairTaskDetails> getRepairMaTypeList(RepairTaskDetails bean) {
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
bean.setCompanyId(companyId);
List<RepairTaskDetails> repairMaTypeList = mapper.getRepairMaTypeList(bean); List<RepairTaskDetails> repairMaTypeList = mapper.getRepairMaTypeList(bean);
return repairMaTypeList; return repairMaTypeList;
} }
@ -211,18 +211,41 @@ public class RepairServiceImpl implements RepairService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult endRepairTask(List<RepairTask> taskList) { public AjaxResult endRepairTask(List<RepairTask> taskList) {
int num = 0;
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
for (RepairTask task : taskList) { for (RepairTask task : taskList) {
int i = mapper.getUnFinish(task); task.setCreateBy(loginUser.getUserid());
List<RepairTaskDetails> detailsList = new ArrayList<>();
List<RepairTaskDetails> repairMaTypeId = mapper.getRepairMaTypeId(task);
// 判断是否全部维修完成
boolean b = repairMaTypeId.stream().allMatch(t -> "1".equals(t.getStatus()));
if (b) {
// 修改状态为 维修完成
mapper.updateTaskStatus(taskList, loginUser.getUserid());
}
for (RepairTaskDetails repairTaskDetails : repairMaTypeId) {
task.setTypeId(repairTaskDetails.getTypeId());
task.setMaId(repairTaskDetails.getMaId());
List<RepairTaskDetails> list = mapper.getDetailsListByTaskId(task);
// 已经提交过的 再次提交不会再生成一遍
if (list.size() > 0) {
mapper.updateCommit(task);
}
detailsList.addAll(list);
}
List<RepairTaskDetails> collect = repairMaTypeId.stream().filter(t -> t.getCommit() == 0).collect(Collectors.toList());
for (RepairTaskDetails taskDetails : collect) {
taskDetails.setTaskId(task.getTaskId());
int i = mapper.getUnFinish(taskDetails);
if (i > 0) { if (i > 0) {
num++;
}
}
if (num == 0) {
throw new ServiceException("选中的数据中包含维修未完成的,请完成维修再进行提交审核"); throw new ServiceException("选中的数据中包含维修未完成的,请完成维修再进行提交审核");
} }
}
int i = mapper.updateTaskStatus(taskList,loginUser.getUserid());
for (RepairTask task : taskList){
task.setCreateBy(loginUser.getUserid());
Long agreementId = mapper.getAgreementId(task); Long agreementId = mapper.getAgreementId(task);
List<RepairTaskDetails> detailsList = mapper.getDetailsListByTaskId(task);
mapper.addTask(task); mapper.addTask(task);
for (RepairTaskDetails details : detailsList) { for (RepairTaskDetails details : detailsList) {
details.setCreateBy(loginUser.getUserid()); details.setCreateBy(loginUser.getUserid());

View File

@ -337,6 +337,9 @@
WHERE WHERE
bai.id = #{id} bai.id = #{id}
</update> </update>
<update id="updateBackInfo">
update back_apply_info set company_id = #{companyId} where id = #{parentId}
</update>
<delete id="del"> <delete id="del">
DELETE DELETE

View File

@ -68,6 +68,16 @@
update_time = now() update_time = now()
where id = #{id} where id = #{id}
</update> </update>
<update id="updateCommit">
update repair_apply_details set commit = 1
where task_id = #{taskId}
<if test="typeId != null and typeId != ''">
and type_id = #{typeId}
</if>
<if test="maId != null and maId != ''">
and ma_id = #{maId}
</if>
</update>
<select id="getRepairTaskList" resultType="com.bonus.sgzb.base.domain.RepairTask"> <select id="getRepairTaskList" resultType="com.bonus.sgzb.base.domain.RepairTask">
SELECT SELECT
@ -219,9 +229,6 @@
left join sys_user su on rad.repairer = su.user_id left join sys_user su on rad.repairer = su.user_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
where rad.task_id = #{taskId} where rad.task_id = #{taskId}
<if test="companyId != null and companyId != ''">
and rad.company_id = #{companyId}
</if>
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
AND (locate(#{keyword}, mm.ma_code) > 0 AND (locate(#{keyword}, mm.ma_code) > 0
or locate(#{keyword}, su.nick_name) > 0 or locate(#{keyword}, su.nick_name) > 0
@ -263,7 +270,14 @@
<select id="getUnFinish" resultType="java.lang.Integer"> <select id="getUnFinish" resultType="java.lang.Integer">
select count(*) select count(*)
from repair_apply_details from repair_apply_details
where task_id = #{taskId} and status = '0' where task_id = #{taskId}
<if test="typeId != null and typeId != ''">
and type_id = #{typeId}
</if>
<if test="maId != null and maId != ''">
and ma_id = #{maId}
</if>
and status = '1'
</select> </select>
<select id="getDicSelect" resultType="com.bonus.sgzb.base.domain.vo.DictVo"> <select id="getDicSelect" resultType="com.bonus.sgzb.base.domain.vo.DictVo">
select s2.id, select s2.id,
@ -282,6 +296,14 @@
company_id as companyId company_id as companyId
from repair_apply_details from repair_apply_details
where task_id = #{taskId} where task_id = #{taskId}
and status = '1'
and commit = 0
<if test="typeId != null and typeId != ''">
and type_id = #{typeId}
</if>
<if test="maId != null and maId != ''">
and ma_id = #{maId}
</if>
</select> </select>
<select id="getRepairTaskListByOne" resultType="com.bonus.sgzb.base.domain.RepairTask"> <select id="getRepairTaskListByOne" resultType="com.bonus.sgzb.base.domain.RepairTask">
SELECT SELECT
@ -341,6 +363,23 @@
GROUP BY rd.task_id,bui.unit_name,bpi.lot_name,su.nick_name GROUP BY rd.task_id,bui.unit_name,bpi.lot_name,su.nick_name
order by tt.create_time desc order by tt.create_time desc
</select> </select>
<select id="getRepairMaTypeId" resultType="com.bonus.sgzb.base.domain.RepairTaskDetails">
SELECT
rad.type_id typeId,
rad.STATUS status,
rad.ma_id maId,
rad.commit commit
FROM
repair_apply_details rad
LEFT JOIN ma_type mt ON rad.type_id = mt.type_id
LEFT JOIN ma_machine mm ON mm.ma_id = rad.ma_id
LEFT JOIN sys_user su ON rad.repairer = su.user_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
WHERE
rad.task_id = #{taskId}
ORDER BY
rad.create_time DESC
</select>
</mapper> </mapper>

View File

@ -83,6 +83,7 @@
and mws.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59') and mws.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
</if> </if>
GROUP BY mws.parent_id,mws.whole_type_name GROUP BY mws.parent_id,mws.whole_type_name
order by mws.create_time desc
</select> </select>
<select id="selectListById" resultType="com.bonus.sgzb.material.domain.MaWholeVo"> <select id="selectListById" resultType="com.bonus.sgzb.material.domain.MaWholeVo">
SELECT SELECT