web端配件领用申请
This commit is contained in:
parent
4b21b55246
commit
b6b7612715
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.gzgqj.business.app.entity;
|
||||
|
||||
import com.bonus.gzgqj.business.plan.entity.PageInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -9,7 +10,7 @@ import java.util.List;
|
|||
* @author 黑子
|
||||
*/
|
||||
@Data
|
||||
public class MachinesVo {
|
||||
public class MachinesVo extends PageInfo {
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
package com.bonus.gzgqj.business.bases.controller;
|
||||
|
||||
import com.bonus.gzgqj.business.app.entity.MachinesVo;
|
||||
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
|
||||
import com.bonus.gzgqj.business.app.service.PartApplyAppServiceImp;
|
||||
import com.bonus.gzgqj.business.bases.entity.PaTypeVo;
|
||||
import com.bonus.gzgqj.business.bases.entity.PartCheckVo;
|
||||
import com.bonus.gzgqj.business.bases.service.PartApplyWebServiceImp;
|
||||
import com.bonus.gzgqj.manager.webResult.ServerResponse;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* web领料申请
|
||||
*
|
||||
* @author 黑子
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/base/partApply")
|
||||
@Slf4j
|
||||
public class PartApplyWebController {
|
||||
|
||||
@Autowired
|
||||
private PartApplyWebServiceImp service;
|
||||
/**
|
||||
* 配件申请-设备 下拉选集合
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getDevList")
|
||||
public PageInfo<MachinesVo> getDevList(MachinesVo dto) {
|
||||
PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
|
||||
List<MachinesVo> list = service.getDevList(dto);
|
||||
PageInfo<MachinesVo> pageInfo = new PageInfo<>(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 依据设备下拉选 -查询 使用单位
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getProInfo")
|
||||
public ServerResponse getProInfo(MachinesVo dto) {
|
||||
return service.getProInfo(dto);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询配件下拉选集合
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getPaTypeList")
|
||||
public PageInfo<PaTypeVo> getPaTypeList(PaTypeVo dto) {
|
||||
PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
|
||||
List<PaTypeVo> list = service.getPaTypeList(dto);
|
||||
PageInfo<PaTypeVo> pageInfo = new PageInfo<>(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增配件信息接口
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("addPartApply")
|
||||
public ServerResponse addPartApply(@RequestBody PartApplyAppVo dto) {
|
||||
return service.addPartApply(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配件申请记录-查询
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getPartApplyList")
|
||||
public PageInfo<PartApplyAppVo> getPartApplyList(PartApplyAppVo dto) {
|
||||
PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
|
||||
List<PartApplyAppVo> list = service.getPartApplyList(dto);;
|
||||
PageInfo<PartApplyAppVo> pageInfo = new PageInfo<>(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 配件申请记录-详情
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getPartApplyDetails")
|
||||
public ServerResponse getPartApplyDetails(PartApplyAppVo dto) {
|
||||
return service.getPartApplyDetails(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片文件上传
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("uploadImage")
|
||||
public ServerResponse uploadImage(HttpServletRequest request) {
|
||||
return service.uploadImage(request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.gzgqj.business.bases.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.bonus.gzgqj.business.plan.entity.PageInfo;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -8,7 +9,7 @@ import lombok.Data;
|
|||
* @author 黑子
|
||||
*/
|
||||
@Data
|
||||
public class PaTypeVo {
|
||||
public class PaTypeVo extends PageInfo {
|
||||
|
||||
|
||||
@Excel(name = "序号", width = 10.0, orderNum = "0")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,228 @@
|
|||
package com.bonus.gzgqj.business.bases.service;
|
||||
|
||||
import com.bonus.gzgqj.business.app.entity.MachinesVo;
|
||||
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
|
||||
import com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo;
|
||||
import com.bonus.gzgqj.business.app.mapper.PartApplyAppMapper;
|
||||
import com.bonus.gzgqj.business.bases.entity.PaTypeVo;
|
||||
import com.bonus.gzgqj.business.plan.entity.FileUploadVo;
|
||||
import com.bonus.gzgqj.business.utils.FileUploadService;
|
||||
import com.bonus.gzgqj.manager.common.util.DateTimeHelper;
|
||||
import com.bonus.gzgqj.manager.common.util.StringHelper;
|
||||
import com.bonus.gzgqj.manager.common.util.StringUtils;
|
||||
import com.bonus.gzgqj.manager.common.util.UserUtil;
|
||||
import com.bonus.gzgqj.manager.webResult.ServerResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
* app 配件申请
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PartApplyWebServiceImp {
|
||||
|
||||
@Autowired
|
||||
private PartApplyAppMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private FileUploadService uploadService;
|
||||
|
||||
/**
|
||||
* 查询设备接口
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public List<MachinesVo> getDevList(MachinesVo dto) {
|
||||
try {
|
||||
List<MachinesVo> list = mapper.getDevList(dto);
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取使用单位
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public ServerResponse getProInfo(MachinesVo dto) {
|
||||
try {
|
||||
MachinesVo machinesVo = mapper.getWfRecordList(dto);
|
||||
if (machinesVo != null){
|
||||
return ServerResponse.createSuccess(machinesVo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createSuccess(new ArrayList<MachinesVo>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配件下拉选集合
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public List<PaTypeVo> getPaTypeList(PaTypeVo dto) {
|
||||
try {
|
||||
List<PaTypeVo> list = mapper.getPaTypeList(dto);
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return new ArrayList<PaTypeVo>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配件信息
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public ServerResponse addPartApply(PartApplyAppVo dto) {
|
||||
try {
|
||||
Long userId = Objects.requireNonNull(UserUtil.getLoginUser()).getUserId();
|
||||
String userName = UserUtil.getLoginUser().getUsername();
|
||||
if (StringHelper.isEmpty(dto.getCreator())) {
|
||||
dto.setCreator(userId.toString());
|
||||
dto.setUpdater(userId.toString());
|
||||
}
|
||||
if (StringHelper.isEmpty(dto.getUserName())) {
|
||||
dto.setUserName(userName);
|
||||
}
|
||||
List<PartApplyDetailAppVo> list = dto.getDetailsList();
|
||||
if (list == null || list.size() < 1) {
|
||||
return ServerResponse.createErroe("请上传配件明细");
|
||||
}
|
||||
if (StringHelper.isNotEmpty(dto.getDeviceId())) {
|
||||
MachinesVo voo = mapper.getDevInfoById(dto.getDeviceId());
|
||||
dto.setDevType(voo.getType());
|
||||
}
|
||||
|
||||
String code = getCode();
|
||||
dto.setCode(code);
|
||||
final int[] applyNum = {0};
|
||||
list.forEach(vo -> {
|
||||
applyNum[0] = applyNum[0] + vo.getApplyNum();
|
||||
});
|
||||
dto.setApplyNum(applyNum[0]);
|
||||
dto.setStatus("1");
|
||||
dto.setStatusType("2");
|
||||
int num = mapper.addPartApply(dto);
|
||||
if (num < 1) {
|
||||
return ServerResponse.createErroe("配件申请失败");
|
||||
}
|
||||
int num2 = mapper.insertDetails(list, dto);
|
||||
if (num2 == list.size()) {
|
||||
return ServerResponse.createSuccess("申请成功", "申请成功");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createErroe("配件申请失败");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getCode() {
|
||||
try {
|
||||
int num = mapper.getSqList();
|
||||
num++;
|
||||
String year = "XS-" + DateTimeHelper.getNowDay();
|
||||
if (num < 10) {
|
||||
return year + "-00" + num;
|
||||
} else if (num < 100) {
|
||||
return year + "-0" + num;
|
||||
}
|
||||
return year + "-" + num;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return "XF-0000000000";
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @param request
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public ServerResponse uploadImage(HttpServletRequest request) {
|
||||
try {
|
||||
String id = request.getParameter("recordId");
|
||||
String bast64 = request.getParameter("bast64");
|
||||
|
||||
if (StringHelper.isEmpty(bast64)) {
|
||||
return ServerResponse.createErroe("请先上传文件");
|
||||
}
|
||||
List<FileUploadVo> fileList = uploadService.uploadImageBast64(bast64, id, "t_part_apply", "使用照片");
|
||||
if (StringUtils.isEmpty(fileList) || fileList.size() < 1) {
|
||||
return ServerResponse.createErroe("文件上传失败");
|
||||
}
|
||||
return ServerResponse.createSuccess("文件上传成功", "文件上传成功");
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createErroe("文件上传失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 配件申请记录查询
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public List<PartApplyAppVo> getPartApplyList(PartApplyAppVo dto) {
|
||||
try {
|
||||
List<PartApplyAppVo> list = mapper.getPartApplyList(dto);
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return new ArrayList<PartApplyAppVo>();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 配件申请详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public ServerResponse getPartApplyDetails(PartApplyAppVo dto) {
|
||||
try {
|
||||
if (StringHelper.isEmpty(dto.getId())) {
|
||||
return ServerResponse.createErroe("清先选择记录");
|
||||
}
|
||||
PartApplyAppVo vo = mapper.getPartApplyDetails(dto);
|
||||
List<FileUploadVo> flieList = uploadService.getFileList(dto.getId(), "t_part_apply", "使用照片");
|
||||
vo.setFileList(flieList);
|
||||
List<PartApplyDetailAppVo> details = mapper.getDetailsList(dto);
|
||||
vo.setDetailsList(details);
|
||||
return ServerResponse.createSuccess("查询成功", vo);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createSuccess("查询失败", new ArrayList<PartApplyAppVo>());
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
</if>
|
||||
dev_code, dev_type,
|
||||
<if test="proId!=null and proId!=''">
|
||||
pro_id ,
|
||||
pro_id,
|
||||
</if>
|
||||
pro_name,
|
||||
apply_num,status_type)values(
|
||||
|
|
@ -23,8 +23,7 @@
|
|||
<if test="proId!=null and proId!=''">
|
||||
#{proId},
|
||||
</if>
|
||||
#{proName}
|
||||
,#{applyNum},#{statusType})
|
||||
#{proName},#{applyNum},#{statusType})
|
||||
</insert>
|
||||
<!--差人申请详情-->
|
||||
<insert id="insertDetails">
|
||||
|
|
@ -38,21 +37,27 @@
|
|||
</insert>
|
||||
|
||||
<select id="getDevList" resultType="com.bonus.gzgqj.business.app.entity.MachinesVo">
|
||||
select mm.id ,mt2.NAME name ,mt3.`NAME` type ,mt.name module ,mm.DEVICE_CODE deviceCode
|
||||
from mm_machines mm
|
||||
left join mm_type mt on mt.id=mm.TYPE and mt.`LEVEL`=4 and mt.IS_ACTIVE=1
|
||||
left join mm_type mt2 on mt.PARENT_ID=mt2.id
|
||||
left join mm_type mt3 on mt2.PARENT_ID=mt3.id
|
||||
where mm.BATCH_STATUS=7
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
and (
|
||||
mt2.NAME like concat('%',#{keyWord},'%') or
|
||||
mt3.NAME like concat('%',#{keyWord},'%') or
|
||||
mm.DEVICE_CODE like concat('%',#{keyWord},'%') or
|
||||
mt.NAME like concat('%',#{keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
|
||||
SELECT
|
||||
mm.id,
|
||||
mm.DEVICE_CODE deviceCode,
|
||||
concat(mt3.NAME,'/',mt2.NAME,'/',mt.NAME) module
|
||||
FROM
|
||||
mm_machines mm
|
||||
LEFT JOIN mm_type mt ON mt.id = mm.TYPE
|
||||
AND mt.`LEVEL` = 4
|
||||
AND mt.IS_ACTIVE = 1
|
||||
LEFT JOIN mm_type mt2 ON mt.PARENT_ID = mt2.id
|
||||
LEFT JOIN mm_type mt3 ON mt2.PARENT_ID = mt3.id
|
||||
WHERE
|
||||
mm.BATCH_STATUS = 7
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
and (
|
||||
mt2.NAME like concat('%',#{keyWord},'%') or
|
||||
mt3.NAME like concat('%',#{keyWord},'%') or
|
||||
mm.DEVICE_CODE like concat('%',#{keyWord},'%') or
|
||||
mt.NAME like concat('%',#{keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
|
|
@ -126,14 +131,13 @@
|
|||
<if test="keyWord!=null and keyWord!=''">
|
||||
and (
|
||||
tpa.code like concat('%',#{keyWord},'%') or
|
||||
tpa.user_name like concat('%',#{keyWord},'%') or
|
||||
tpa.remark like concat('%',#{keyWord},'%') or
|
||||
tpa.pro_name like concat('%',#{keyWord},'%')
|
||||
tpa.user_name like concat('%',#{keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="startDay!=null and startDay!='' and endDay!=null and endDay!='' ">
|
||||
and STR_TO_DATE(tpa.create_time, '%Y-%m-%d') between STR_TO_DATE(#{startDay} ,'%Y-%m-%d') AND STR_TO_DATE(#{endDay},'%Y-%m-%d')
|
||||
</if>
|
||||
</where>
|
||||
|
||||
|
||||
</select>
|
||||
<select id="getPartApplyDetails" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
|
||||
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
|
||||
|
|
|
|||
Loading…
Reference in New Issue