后台维修代码提交

This commit is contained in:
liuchuan 2023-12-17 18:50:22 +08:00
parent c0e2037689
commit eba9de34e8
13 changed files with 169 additions and 68 deletions

View File

@ -46,6 +46,17 @@ public class MaTypeController extends BaseController {
return AjaxResult.success(maTypeList);
}
/**
* 工机具类型下拉树
* @return 结果
*/
@ApiOperation(value = "工机具类型下拉树")
@GetMapping("/getMaTypeSelect")
public AjaxResult getMaTypeSelect(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId){
List<TreeSelect> maTypeList = iTypeService.getMaTypeSelect(typeName, parentId);
return AjaxResult.success(maTypeList);
}
@ApiOperation(value = "获取机具设备的具体规格")
@GetMapping(value = "/selectMaTypeTreeByLevel")
public AjaxResult selectMaTypeTreeByLevel(@RequestParam(value = "typeId") String typeId) {

View File

@ -1,10 +1,12 @@
package com.bonus.sgzb.base.controller;
import cn.hutool.http.server.HttpServerRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bonus.sgzb.base.domain.*;
import com.bonus.sgzb.base.domain.vo.TreeSelect;
import com.bonus.sgzb.base.domain.vo.dictVo;
import com.bonus.sgzb.base.service.RepairService;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
@ -17,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@ -77,7 +80,7 @@ public class RepairController extends BaseController {
@ApiOperation(value = "快捷维修记录")
@Log(title = "快捷维修记录", businessType = BusinessType.INSERT)
@PostMapping("/fastRepairApply")
public AjaxResult fastRepairApply(List<RepairTaskDetails> list) {
public AjaxResult fastRepairApply(@RequestBody List<RepairTaskDetails> list) {
AjaxResult ajaxResult = service.fastRepairApply(list);
return ajaxResult;
}
@ -88,8 +91,7 @@ public class RepairController extends BaseController {
@ApiOperation(value = "完成维修")
@Log(title = "完成维修", businessType = BusinessType.INSERT)
@PostMapping("/completeRepair")
public AjaxResult completeRepair(List<Long> ids) {
public AjaxResult completeRepair(@RequestBody ArrayList<Long> ids) {
return toAjax(service.completeRepair(ids));
}
@ -99,9 +101,8 @@ public class RepairController extends BaseController {
@ApiOperation(value = "提交审核")
@Log(title = "提交审核", businessType = BusinessType.INSERT)
@PostMapping("/endRepairTask")
public AjaxResult endRepairTask(List<RepairTask> taskList) {
return toAjax(service.endRepairTask(taskList));
public AjaxResult endRepairTask(@RequestBody ArrayList<RepairTask> taskList) {
return service.endRepairTask(taskList);
}
/**
@ -114,6 +115,15 @@ public class RepairController extends BaseController {
return AjaxResult.success(list);
}
/**
* 字典下拉选
*/
@GetMapping("/getDicSelect")
public AjaxResult getDicSelect(@RequestParam String value)
{
List<dictVo> list = service.getDicSelect(value);
return AjaxResult.success(list);
}
}

View File

@ -121,5 +121,5 @@ public class RepairApplyRecord {
* 损坏照片id
*/
@ApiModelProperty(value = "损坏照片id")
private String fileId;
private String fileIds;
}

View File

@ -75,7 +75,7 @@ public class RepairTaskDetails {
* 维修人
*/
@ApiModelProperty(value = "维修人")
private Long repairer;
private String repairer;
private String keyword;//关键字
private String typeId;//规格ID
private Long companyId;//规格ID

View File

@ -0,0 +1,17 @@
package com.bonus.sgzb.base.domain.vo;
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.io.Serializable;
/**
* @author c liu
* @date 2023/12/17
*/
@Data
public class dictVo extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
}

View File

@ -74,4 +74,5 @@ public interface MaTypeMapper {
List<MaType> selectMaTypeListByLevelNotFour(String parentId);
List<MaType> getMaTypeSelect(String parentId);
}

View File

@ -4,10 +4,12 @@ import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairPartDetails;
import com.bonus.sgzb.base.domain.RepairTask;
import com.bonus.sgzb.base.domain.RepairTaskDetails;
import com.bonus.sgzb.base.domain.vo.dictVo;
import com.bonus.sgzb.system.api.domain.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
/**
@ -36,11 +38,11 @@ public interface RepairMapper {
int addPart(RepairPartDetails partDetails);
int completeRepair(List<Long> ids,Long userId);
int completeRepair(@Param("ids") ArrayList<Long> ids, @Param("userId")Long userId);
List<SysUser> selectUserList();
int updateTaskStatus(List<RepairTask> taskList, Long userid);
int updateTaskStatus(@Param("taskList")List<RepairTask> taskList,@Param("userId") Long userid);
int addTask(RepairTask task);
@ -49,4 +51,9 @@ public interface RepairMapper {
int createAgreementTask(RepairTask task);
int updateRepairedNumTwo(@Param("id")Long id, @Param("repairNum")int repairNum, @Param("userId")Long userid);
int getUnFinish(RepairTask task);
List<dictVo> getDicSelect(String value);
}

View File

@ -11,6 +11,7 @@ import java.util.List;
public interface ITypeService {
List<TreeSelect> getMaTypeList(String typeName, String parentId);
List<TreeSelect> getMaTypeSelect(String typeName, String parentId);
List<MaType> getListByMaType(Long typeId,String typeName);
@ -67,4 +68,6 @@ public interface ITypeService {
List<MaType> getListByParentId(Long typeId, String typeName);
List<MaType> getEquipmentType(Long typeId, String typeName);
}

View File

@ -4,9 +4,11 @@ import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairTask;
import com.bonus.sgzb.base.domain.RepairTaskDetails;
import com.bonus.sgzb.base.domain.vo.TreeSelect;
import com.bonus.sgzb.base.domain.vo.dictVo;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.system.api.domain.SysUser;
import java.util.ArrayList;
import java.util.List;
/**
@ -26,9 +28,11 @@ public interface RepairService {
AjaxResult fastRepairApply(List<RepairTaskDetails> list);
int completeRepair(List<Long> ids);
int completeRepair(ArrayList<Long> ids);
List<SysUser> selectUserList();
int endRepairTask(List<RepairTask> taskList);
AjaxResult endRepairTask(List<RepairTask> taskList);
List<dictVo> getDicSelect(String value);
}

View File

@ -157,6 +157,16 @@ public class MaTypeServiceImpl implements ITypeService {
return treeSelectList;
}
@Override
public List<TreeSelect> getMaTypeSelect(String typeName, String parentId) {
List<MaType> maTypes = maTypeMapper.getMaTypeSelect(parentId);
List<TreeSelect> treeSelectList = buildDeptTreeSelect(maTypes);
//如果没有查询到那么返回空
return treeSelectList;
}
/**
* 根据左列表类型id查询右表格
*

View File

@ -1,14 +1,18 @@
package com.bonus.sgzb.base.service.impl;
import cn.hutool.http.server.HttpServerRequest;
import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairPartDetails;
import com.bonus.sgzb.base.domain.RepairTask;
import com.bonus.sgzb.base.domain.RepairTaskDetails;
import com.bonus.sgzb.base.domain.vo.TreeSelect;
import com.bonus.sgzb.base.domain.vo.dictVo;
import com.bonus.sgzb.base.mapper.RepairMapper;
import com.bonus.sgzb.base.service.RepairService;
import com.bonus.sgzb.common.core.constant.TokenConstants;
import com.bonus.sgzb.common.core.utils.SpringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.service.TokenService;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.api.model.LoginUser;
@ -16,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -28,45 +34,32 @@ public class RepairServiceImpl implements RepairService {
@Autowired
private RepairMapper mapper;
@Resource
private TokenService TokenService;
@Override
public List<RepairTask> getRepairTaskList(RepairTask bean) {
List<RepairTask> repairTaskList = mapper.getRepairTaskList(bean);
for (RepairTask repairTask : repairTaskList){
List<String> typeList = mapper.getTypeList(repairTask.getTaskId());
if (typeList != null && typeList.size() > 0){
StringBuilder type = new StringBuilder();
for (String s : typeList){
type.append(s);
type.append("");
}
repairTask.setType(String.valueOf(type));
}
}
return repairTaskList;
}
@Override
public List<RepairTaskDetails> getRepairMaTypeList(RepairTask bean) {
List<RepairTaskDetails> repairMaTypeList = mapper.getRepairMaTypeList(bean);
for (RepairTaskDetails repairTaskDetails : repairMaTypeList){
String typeName = mapper.getType(repairTaskDetails.getTypeId());
repairTaskDetails.setTypeName(typeName);
}
return repairMaTypeList;
}
@Override
@Transactional
public AjaxResult submitRepairApply(RepairApplyRecord bean) {
public AjaxResult submitRepairApply( RepairApplyRecord bean) {
RepairTaskDetails details = mapper.getById(bean.getId());
LoginUser loginUser = SecurityUtils.getLoginUser();
bean.setCreateBy(loginUser.getUserid());
List<RepairPartDetails> partList = bean.getPartList();
if (partList != null && partList.size()>0){
bean.setRepairNum(partList.get(0).getRepairNum());
bean.setRepairer(partList.get(0).getRepairer());
}
switch (bean.getRepairType()) {
case "1":{
@ -92,6 +85,7 @@ public class RepairServiceImpl implements RepairService {
int num = scrapNum + details.getRepairedNum();
if (num > details.getRepairNum()) {
return AjaxResult.error("维修数量大于维修总量");
//添加维修记录
}
mapper.updateScrapNum(bean.getId(), scrapNum,loginUser.getUserid());
break;
@ -111,7 +105,7 @@ public class RepairServiceImpl implements RepairService {
mapper.addPart(partDetails);
}
}
if (!bean.getRepairType().equals("1")){
if (bean.getRepairType().equals("2")){
bean.setPartName(partList.get(0).getPartName());
bean.setPartType(partList.get(0).getPartType());
bean.setRepairContent(partList.get(0).getRepairContent());
@ -119,34 +113,46 @@ public class RepairServiceImpl implements RepairService {
bean.setPartPrice(partList.get(0).getPartPrice());
bean.setPartNum(partList.get(0).getPartNum());
}
bean.setRepairer(partList.get(0).getRepairer());
}
mapper.addRecord(bean);
return AjaxResult.success();
}
@Override
@Transactional
public AjaxResult fastRepairApply(List<RepairTaskDetails> list) {
LoginUser loginUser = SecurityUtils.getLoginUser();
for (RepairTaskDetails bean : list){
int repaired_num = bean.getRepairNum() - bean.getRepairedNum() - bean.getScrapNum();
int repairedNum = bean.getRepairNum() - bean.getRepairedNum() - bean.getScrapNum();
if (repairedNum <= 0){
return AjaxResult.error("选中的数据中包含待维修数量为0的机具请重新选择");
}
RepairApplyRecord partDetails = new RepairApplyRecord();
partDetails.setTaskId(bean.getTaskId());
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setRepairNum(repaired_num);
partDetails.setRepairNum(repairedNum);
partDetails.setRepairType("1");
partDetails.setCreateBy(loginUser.getUserid());
partDetails.setCompanyId(bean.getCompanyId());
mapper.addRecord(partDetails);
int i = repairedNum + bean.getRepairedNum();
mapper.updateRepairedNumTwo(bean.getId(),i,loginUser.getUserid());
}
return AjaxResult.success();
}
@Override
@Transactional
public int endRepairTask(List<RepairTask> taskList) {
public AjaxResult endRepairTask(List<RepairTask> taskList) {
LoginUser loginUser = SecurityUtils.getLoginUser();
for (RepairTask task : taskList){
int i = mapper.getUnFinish(task);
if (i > 0){
return AjaxResult.error("选中的数据中包含维修未完成的,请完成维修再进行审核");
}
}
int i = mapper.updateTaskStatus(taskList,loginUser.getUserid());
for (RepairTask task : taskList){
task.setCreateBy(loginUser.getUserid());
@ -155,11 +161,16 @@ public class RepairServiceImpl implements RepairService {
task.setAgreementId(agreementId);
mapper.createAgreementTask(task);
}
return i;
return AjaxResult.success();
}
@Override
public int completeRepair(List<Long> ids) {
public List<dictVo> getDicSelect(String value) {
return mapper.getDicSelect(value);
}
@Override
public int completeRepair(ArrayList<Long> ids) {
LoginUser loginUser = SecurityUtils.getLoginUser();
return mapper.completeRepair(ids,loginUser.getUserid());
}

View File

@ -293,6 +293,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
level != 4 and m.status = '0'
</where>
</select>
<select id="getMaTypeSelect" resultType="com.bonus.sgzb.base.api.domain.MaType">
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type,
m.lease_price, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id
from ma_type m
<where>
m.status = '0'
</where>
</select>
<select id="getListByParentId" resultMap="MaTypeResult">
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.unit_name, m.manage_type,
@ -338,4 +348,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
</mapper>

View File

@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bonus.sgzb.base.mapper.RepairMapper">
<insert id="addRecord">
insert into repair_apply_record (task_id,ma_id,type_id,repair_num,scrap_num,repair_type,create_by,create_time,repair_content,company_id,scrap_reason,scrap_type,supplier_id,part_num,part_price,part_type,part_name,repairer)
values (#{taskId},#{maId},#{typeId},#{repairNum},#{scrapNum},#{repairType},#{createBy},now(),#{repairContent},#{companyId},#{scrapReason},#{scrapType},#{supplierId},#{partNum},#{partPrice},#{partType},#{partName},#{repairer});
insert into repair_apply_record (task_id,ma_id,type_id,repair_num,scrap_num,repair_type,create_by,create_time,repair_content,company_id,scrap_reason,scrap_type,supplier_id,part_num,part_price,part_type,part_name,repairer,file_ids)
values (#{taskId},#{maId},#{typeId},#{repairNum},#{scrapNum},#{repairType},#{createBy},now(),#{repairContent},#{companyId},#{scrapReason},#{scrapType},#{supplierId},#{partNum},#{partPrice},#{partType},#{partName},#{repairer},#{fileIds});
</insert>
<insert id="addPart">
insert into repair_part_details (task_id,ma_id,type_id,part_id,part_num,part_cost,part_type,create_by,create_time,company_id,repair_content)
@ -62,29 +62,32 @@
<select id="getRepairTaskList" resultType="com.bonus.sgzb.base.domain.RepairTask">
SELECT
ts.task_id as taskId,
ts.CODE AS repairCode,
bui.unit_name AS backUnit,
bpi.pro_name AS backPro,
su.user_name AS createUser,
ts.create_time AS createTime,
bai.CODE AS backCode,
ts.task_status AS repairStatus,
ts.company_id AS companyId
rd.task_id,
tt.CODE AS repairCode,
bui.unit_name AS backUnit,
bpi.pro_name AS backPro,
su.user_name AS createUser,
tt.create_time AS createTime,
bai.CODE AS backCode,
sd.name AS repairStatus,
tt.company_id AS companyId,
GROUP_CONCAT(DISTINCT mt2.type_name) as type
FROM
tm_task ts
LEFT JOIN repair_apply_details rad ON ts.task_id = rad.task_id
LEFT JOIN back_apply_info bai ON rad.back_id = bai.id
LEFT JOIN tm_task_agreement tta ON bai.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai2 ON tta.agreement_id = bai2.agreement_id
LEFT JOIN bm_unit_info bui ON bai2.unit_id = bui.unit_id
LEFT JOIN bm_project_info bpi ON bai2.project_id = bpi.pro_id
left join sys_user su on rad.create_by = su.user_id
where ts.task_type = '41'
GROUP BY ts.task_id, bui.unit_name,bpi.pro_name,bai.code,su.user_name
repair_apply_details rd
LEFT JOIN ma_type mt on rd.type_id = mt.type_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN tm_task tt on rd.task_id = tt.task_id
LEFT JOIN back_apply_info bai ON rd.back_id = bai.id
LEFT JOIN tm_task_agreement tta ON bai.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai2 ON tta.agreement_id = bai2.agreement_id
LEFT JOIN bm_unit_info bui ON bai2.unit_id = bui.unit_id
LEFT JOIN bm_project_info bpi ON bai2.project_id = bpi.pro_id
left join sys_user su on rd.create_by = su.user_id
left join sys_dic sd on sd.id = tt.task_status
GROUP BY rd.task_id,bui.unit_name,bpi.pro_name,bai.code,su.user_name
<if test="keyword != null and keyword != ''">
AND (locate(#{keyword}, su.user_name) > 0
or locate(#{keyword}, ts.CODE) > 0)
or locate(#{keyword}, tt.CODE) > 0)
</if>
<if test="backUnit != null and backUnit != ''">
AND bui.unit_id = #{backUnit}
@ -93,21 +96,21 @@
AND bpi.pro_id = #{backPro}
</if>
<if test="backCode != null and backCode != ''">
AND bai.CODE = #{backCode}
AND locate(#{backCode}, bai.CODE) > 0)
</if>
<if test="repairStatus != null and repairStatus != ''">
AND ts.task_status = #{repairStatus}
AND tt.task_status = #{repairStatus}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND ts.create_time between #{startTime} and #{endTime}
</if>
</select>
<select id="getRepairMaTypeList" resultType="com.bonus.sgzb.base.domain.RepairTaskDetails">
select rad.id as id,
rad.task_id as taskId,
rad.ma_id as maId,
mt2.type_name as typeName,
mt.type_name as type,
mm.ma_code as code,
rad.repair_num as repairNum,
@ -115,13 +118,14 @@
rad.scrap_num as scrapNum,
rad.status as status,
su.user_name as repairer,
rad.update_time as updateTime,
rad.type_id as typeId
rad.update_time as updateTime,
rad.type_id as typeId
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
where rad.task_id = #{taskId}
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 = '4'
</select>
<select id="getTypeList" resultType="java.lang.String">
SELECT
@ -171,5 +175,17 @@
from tm_task_agreement
where task_id = #{taskId}
</select>
<select id="getUnFinish" resultType="java.lang.Integer">
select count(*)
from repair_apply_details
where task_id = #{taskId} and status = '0'
</select>
<select id="getDicSelect" resultType="com.bonus.sgzb.base.domain.vo.dictVo">
select s2.id,
s2.name
from sys_dic s1
left join sys_dic s2 on s2.p_id = s1.id
where s1.value = #{value} and s2.status = 0
</select>
</mapper>