退料审核通过和驳回逻辑提交

This commit is contained in:
liang.chao 2024-02-29 19:24:27 +08:00
parent 1f5869efe5
commit 32b9538771
9 changed files with 263 additions and 58 deletions

View File

@ -22,10 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 登录校验方法
@ -212,7 +209,8 @@ public class SysLoginService {
*/
public void register(RegisterBody registerBody) {
String username = registerBody.getUsername();
String password = registerBody.getPassword();
// 随机生成一个10位数密码
String password = generateRandomPassword(10);
String phone = registerBody.getPhone();
// 用户名或密码为空 错误
if (StringUtils.isAnyBlank(username, password)) {
@ -270,12 +268,16 @@ public class SysLoginService {
}
public static long[] convertToLongArray(int num) {
String numStr = Integer.toString(num);
long[] longArray = new long[numStr.length()];
for (int i = 0; i < numStr.length(); i++) {
longArray[i] = Long.parseLong(String.valueOf(numStr.charAt(i)));
// 生成一个随时length位数密码
public static String generateRandomPassword(int length) {
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
Random random = new Random();
StringBuilder password = new StringBuilder();
for (int i = 0; i < length; i++) {
int index = random.nextInt(characters.length());
password.append(characters.charAt(index));
}
return longArray;
return password.toString();
}
}

View File

@ -45,8 +45,10 @@ public class LeaseOutDetailsController extends BaseController {
int i = leaseOutDetailsService.bindMachineByRfid(maMachine);
if (i == 0) {
return AjaxResult.success("绑定成功");
} else if (i == 1) {
return AjaxResult.error("未查询到该设备");
} else {
return AjaxResult.error("绑定失败");
return AjaxResult.error("该设备已绑定");
}
}

View File

@ -52,10 +52,14 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
@Override
public int bindMachineByRfid(MaMachine maMachine) {
List<MaMachine> maMachineByMaIdAndMaCode = maMachineMapper.getMaMachineByMaIdAndMaCode(maMachine);
if (CollUtil.isNotEmpty(maMachineByMaIdAndMaCode)){
if (CollUtil.isNotEmpty(maMachineByMaIdAndMaCode)) {
for (MaMachine machine : maMachineByMaIdAndMaCode) {
machine.setRfidCode(maMachine.getRfidCode());
maMachineMapper.updateMaMachine(machine);
if (StringUtils.isBlank(machine.getRfidCode())) {
machine.setRfidCode(maMachine.getRfidCode());
maMachineMapper.updateMaMachine(machine);
} else {
return 2;
}
}
return 0;
}
@ -65,9 +69,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
@Override
@Transactional
public AjaxResult submitOutRfid(List<LeaseOutDetails> recordList) {
for (LeaseOutDetails bean : recordList){
for (LeaseOutDetails bean : recordList) {
AjaxResult ajaxResult = submitOut(bean);
if (ajaxResult.isError()){
if (ajaxResult.isError()) {
return ajaxResult;
}
}
@ -128,9 +132,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
leaseOutDetailsMapper.updateTaskStatus(taskId, 34);
}
int j = insSltInfo(taskId, record);
if (j > 0){
if (j > 0) {
return AjaxResult.success("领料出库成功!");
}else {
} else {
return AjaxResult.error("出库失败,更新设备规格库存数量时出错!");
}
@ -146,25 +150,25 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
return AjaxResult.error("出库操作失败,更新领料数量及状态时出错!");
}
public int insSltInfo(String taskId,LeaseOutDetails record){
public int insSltInfo(String taskId, LeaseOutDetails record) {
SltAgreementInfo sltAgreementInfo = leaseOutDetailsMapper.getSltAgreementInfo(record);
if (sltAgreementInfo != null){
if (sltAgreementInfo != null) {
double num = Double.parseDouble(sltAgreementInfo.getNum());
double outNum = record.getOutNum();
sltAgreementInfo.setNum(String.valueOf(num + outNum));
return leaseOutDetailsMapper.updSltInfo(sltAgreementInfo);
}else {
} else {
String agreementId = leaseOutDetailsMapper.getAgreementId(taskId);
String protocol = leaseOutDetailsMapper.getProtocol(agreementId);
MaType ma = leaseOutDetailsMapper.getMaType(record.getTypeId());
if (protocol.isEmpty()){
if (protocol.isEmpty()) {
ma.setFinalPrice(ma.getLeasePrice());
}else {
if (protocol.equals("1")){
} else {
if (protocol.equals("1")) {
ma.setFinalPrice(ma.getLeasePrice());
}else if (protocol.equals("2")){
} else if (protocol.equals("2")) {
ma.setFinalPrice(ma.getRentPrice());
}else {
} else {
ma.setFinalPrice(ma.getLeasePrice());
}
}
@ -198,7 +202,6 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
}
@Override
public List<MaMachine> getMaMachineByRfidCode(String rfidCode) {
return maMachineMapper.getMaMachineByRfidCode(rfidCode);

View File

@ -80,24 +80,47 @@ public class BackApplyController extends BaseController {
/**
* 退料申请详情
*/
@ApiOperation(value = "退料申请详情")
@GetMapping("/getView")
public TableDataInfo getView(BackApplyInfo bean) {
@ApiOperation(value = "退料申请(查看)")
@GetMapping("/getViewByApply")
public TableDataInfo getViewByApply(BackApplyInfo bean) {
startPage();
List<BackApplyInfo> list = backApplyService.getView(bean);
bean.setFlag(0);
List<BackApplyInfo> list = backApplyService.getViewByApply(bean);
return getDataTable(list);
}
/**
* 退料申请详情--用于退料单不带分页
*/
@ApiOperation(value = "退料单")
@GetMapping("/materialReturnNote")
public AjaxResult materialReturnNote(BackApplyInfo bean) {
@ApiOperation(value = "退料申请(退料单、审批)")
@GetMapping("/materialReturnNoteByApply")
public AjaxResult materialReturnNoteByApply(BackApplyInfo bean) {
bean.setFlag(1);
List<BackApplyInfo> list = backApplyService.getViewByApply(bean);
return success(list);
}
/**
* 退料审核详情
*/
@ApiOperation(value = "退料审核(查看)")
@GetMapping("/getViewByExamine")
public TableDataInfo getViewByExamine(BackApplyInfo bean) {
startPage();
List<BackApplyInfo> list = backApplyService.getView(bean);
return getDataTable(list);
}
/**
* 退料审核详情-不带分页
*/
@ApiOperation(value = "退料审核(审批/退料单)")
@GetMapping("/materialReturnNoteByExamine")
public AjaxResult materialReturnNoteByExamine(BackApplyInfo bean) {
List<BackApplyInfo> list = backApplyService.getView(bean);
return success(list);
}
/**
* 退料申请详情修改
*/
@ -223,12 +246,24 @@ public class BackApplyController extends BaseController {
/**
* 退料申请导出
*/
@ApiOperation("退料申请导出")
@Log(title = "退料申请导出", businessType = BusinessType.EXPORT)
@ApiOperation("退料申请列表导出")
@Log(title = "退料申请列表导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BackApplyInfo bean) {
public void exportApply(HttpServletResponse response, BackApplyInfo bean) {
List<BackApplyInfo> list = backApplyService.getBackApplyList(bean);
ExcelUtil<BackApplyInfo> util = new ExcelUtil<BackApplyInfo>(BackApplyInfo.class);
util.exportExcel(response, list, "退料申请数据");
}
/**
* 退料审核导出
*/
@ApiOperation("退料审核列表导出")
@Log(title = "退料审核列表导出", businessType = BusinessType.EXPORT)
@PostMapping("/exportExamine")
public void exportExamine(HttpServletResponse response, BackApplyInfo bean) {
List<BackApplyInfo> list = backApplyService.getBackAuditList(bean);
ExcelUtil<BackApplyInfo> util = new ExcelUtil<BackApplyInfo>(BackApplyInfo.class);
util.exportExcel(response, list, "退料申请数据");
}
}

View File

@ -21,10 +21,27 @@ public class BackApplyInfo extends BaseEntity {
@ApiModelProperty(value = "退料ID")
private Long id;
@ApiModelProperty(value="工程id")
private Long projectId;
/**
* 工程名称
*/
@ApiModelProperty(value="工程名称")
private String proName;
/** 退料ID-字符串 */
@ApiModelProperty(value = "退料ID-字符串")
private String ids;
private String applyStatus;
/**
* 装备管理方式(0编号 1计数)
*/
@ApiModelProperty(value = "装备管理方式名称")
private String manageTypeName;
private int flag;
/** 退料单号 */
@Excel(name = "退料单号")
@ApiModelProperty(value = "退料单号")

View File

@ -23,6 +23,7 @@ public interface BackApplyMapper {
List<BackApplyInfo> getBackApplyList(BackApplyInfo bean);
List<BackApplyInfo> getBackApplyListByAdmin(BackApplyInfo bean);
List<BackApplyInfo> getBackApplyListByAdmin1(BackApplyInfo bean);
/**
* 获取在用物料列表
@ -73,6 +74,7 @@ public interface BackApplyMapper {
* @return
*/
List<BackApplyInfo> getView(BackApplyInfo bean);
List<BackApplyInfo> getViewByApply(BackApplyInfo bean);
/**
* 修改

View File

@ -70,6 +70,7 @@ public interface BackApplyService {
* @return
*/
List<BackApplyInfo> getView(BackApplyInfo bean);
List<BackApplyInfo> getViewByApply(BackApplyInfo bean);
/**
* 退料申请详情修改

View File

@ -41,7 +41,7 @@ public class BackApplyServiceImpl implements BackApplyService {
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
if (roles.contains("admin")) {
//管理员可以看到所有退料申请
return backApplyMapper.getBackApplyListByAdmin(bean);
return backApplyMapper.getBackApplyListByAdmin1(bean);
}
//个人只能看到自己的申请的退料
String username = SecurityUtils.getLoginUser().getUsername();
@ -126,7 +126,30 @@ public class BackApplyServiceImpl implements BackApplyService {
@Override
public List<BackApplyInfo> getView(BackApplyInfo bean) {
return backApplyMapper.getView(bean);
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
if (companyId != null) {
bean.setCompanyId(companyId.toString());
return backApplyMapper.getView(bean);
} else {
return backApplyMapper.getView(bean);
}
}
@Override
public List<BackApplyInfo> getViewByApply(BackApplyInfo bean) {
List<BackApplyInfo> viewByApply = backApplyMapper.getViewByApply(bean);
if (bean.getFlag() == 1) {
List<BackApplyInfo> backApplyInfos = new ArrayList<>();
for (BackApplyInfo backApplyInfo : viewByApply) {
if ("2".equals(backApplyInfo.getStatus()) || "4".equals(backApplyInfo.getStatus())) {
backApplyInfos.add(backApplyInfo);
}
}
return backApplyInfos;
}
return viewByApply;
}
@Override
@ -161,7 +184,7 @@ public class BackApplyServiceImpl implements BackApplyService {
@Override
public AjaxResult audit(BackApplyInfo bean) {
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
String username = SecurityUtils.getLoginUser().getUsername();
Long userid = SecurityUtils.getLoginUser().getUserid();
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
int num = 0;
if (!StringUtils.isEmpty(bean.getIds())) {
@ -169,18 +192,26 @@ public class BackApplyServiceImpl implements BackApplyService {
for (int i = 0; i < ids.length; i++) {
String id = ids[i];
bean.setId(Long.valueOf(id));
if (roles.contains("jjfgs") || roles.contains("admin")) {
bean.setCompanyId(companyId.toString());
bean.setCreateBy(username);
if (roles.contains("admin")) {
bean.setCreateBy(userid.toString());
bean.setStatus("1");
int re = backApplyMapper.audit(bean);
if (re < 1) {
return AjaxResult.error("审核失败");
}
}
if (roles.contains("tsfgs") || roles.contains("admin")) {
if (roles.contains("jjfgs")) {
bean.setCompanyId(companyId.toString());
bean.setCreateBy(username);
bean.setCreateBy(userid.toString());
bean.setStatus("1");
int re = backApplyMapper.audit(bean);
if (re < 1) {
return AjaxResult.error("审核失败");
}
}
if (roles.contains("tsfgs")) {
bean.setCompanyId(companyId.toString());
bean.setCreateBy(userid.toString());
bean.setStatus("3");
int re = backApplyMapper.audit(bean);
if (re < 1) {
@ -209,7 +240,7 @@ public class BackApplyServiceImpl implements BackApplyService {
@Override
public AjaxResult refuse(BackApplyInfo bean) {
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
String username = SecurityUtils.getLoginUser().getUsername();
Long userId = SecurityUtils.getLoginUser().getSysUser().getUserId();
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
int num = 0;
if (!StringUtils.isEmpty(bean.getIds())) {
@ -217,18 +248,26 @@ public class BackApplyServiceImpl implements BackApplyService {
for (int i = 0; i < ids.length; i++) {
String id = ids[i];
bean.setId(Long.valueOf(id));
if (roles.contains("jjfgs") || roles.contains("admin")) {
bean.setCompanyId(companyId.toString());
bean.setCreateBy(username);
if (roles.contains("admin")) {
bean.setCreateBy(userId.toString());
bean.setStatus("2");
int re = backApplyMapper.refuse(bean);
if (re < 1) {
return AjaxResult.error("驳回失败");
}
}
if (roles.contains("tsfgs") || roles.contains("admin")) {
if (roles.contains("jjfgs")) {
bean.setCompanyId(companyId.toString());
bean.setCreateBy(username);
bean.setCreateBy(userId.toString());
bean.setStatus("2");
int re = backApplyMapper.refuse(bean);
if (re < 1) {
return AjaxResult.error("驳回失败");
}
}
if (roles.contains("tsfgs")) {
bean.setCompanyId(companyId.toString());
bean.setCreateBy(userId.toString());
bean.setStatus("4");
int re = backApplyMapper.refuse(bean);
if (re < 1) {
@ -243,7 +282,7 @@ public class BackApplyServiceImpl implements BackApplyService {
}
}
}
if (num == taskIdById.size()) {
if (num > 0) {
bean.setTaskStatus("101");
backApplyMapper.updateTmTask(bean);
}

View File

@ -257,7 +257,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE
bai.id = #{id}
<if test="companyId != null and companyId != ''">
and bai.company_id = #{companyId},
and bai.company_id = #{companyId}
</if>
</update>
@ -265,11 +265,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UPDATE tm_task tt
LEFT JOIN back_apply_info bai ON bai.task_id = tt.task_id
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
SET bad.audit_num=bad.pre_num,bai.direct_audit_by=#{createBy},bad.status=#{status},bai.direct_audit_time=NOW()
SET bad.audit_num=bad.pre_num,bai.direct_audit_by=#{createBy},bai.status=#{status},bai.direct_audit_time=NOW()
WHERE
bai.id = #{id}
<if test="companyId != null and companyId != ''">
and bai.company_id = #{companyId},
and bai.company_id = #{companyId}
</if>
</update>
<update id="updateTmTask">
@ -304,6 +304,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bai.id,
bai.`code`,
bai.back_person as backPerson,
bai.`status` as applyStatus,
bai.phone,
bpl.lot_id as lotId,
bpl.lot_name as lotName,
@ -352,7 +353,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="time != null and time != ''">
and bai.back_time =#{time}
</if>
GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
GROUP BY bai.task_id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
ORDER BY bai.create_time desc
</select>
@ -433,6 +434,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM
back_apply_details bad
LEFT JOIN back_apply_info bai ON bai.id = bad.parent_id
LEFT JOIN tm_task tt on bai.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta ON tta.task_id = bai.task_id
LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot lot ON lot.lot_id = bagi.project_id
@ -443,7 +445,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE
bai.id = #{id}
bai.task_id = #{taskId}
<if test="companyId != null and companyId != ''">
and bai.company_id = #{companyId}
</if>
<if test="keyWord != null and keyWord != ''">
and (mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%'))
@ -588,8 +593,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT
bai.id,
bai.`code`,
bai.`status` as applyStatus,
bai.back_person as backPerson,
bai.phone,
bai.task_id as taskId,
bpl.lot_id as lotId,
bpl.lot_name as lotName,
bui.unit_id as unitId,
@ -648,5 +655,102 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(SELECT * FROM back_apply_info bai2 WHERE bai2.id = #{id}) dd
on bai1.task_id = dd.task_id
</select>
<select id="getViewByApply" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
SELECT
bai.back_person AS backPerson,
bai.phone AS phone,
bai.back_time as backTime,
lot.lot_name AS lotName,
lot.lot_id as proId,
lot.pro_id as projectId,
lot.lot_name as proName,
unit.unit_name AS unitName,
unit.unit_id AS unitId,
mt.type_name typeCode,
mt.num,
case WHEN mt.manage_type = '0' then '编号' else '计数' end manageTypeName,
mt2.type_name AS typeName,
bagi.agreement_code as agreementCode,
bai.`status` as `status`,
bad.pre_num AS num
FROM
back_apply_details bad
LEFT JOIN back_apply_info bai ON bai.id = bad.parent_id
LEFT JOIN tm_task tt on bai.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta ON tta.task_id = bai.task_id
LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot lot ON lot.lot_id = bagi.project_id
LEFT JOIN bm_unit_info unit ON unit.unit_id = bagi.unit_id
LEFT JOIN ma_type mt ON mt.type_id = bad.type_id
LEFT JOIN ma_type mt1 ON mt1.type_id = bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE
bai.task_id in (SELECT task_id from back_apply_info WHERE id = #{id})
<if test="keyWord != null and keyWord != ''">
and (mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%'))
</if>
</select>
<select id="getBackApplyListByAdmin1" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
SELECT
bai.id,
bai.`code`,
bai.`status` as applyStatus,
bai.back_person as backPerson,
bai.phone,
bai.task_id as taskId,
bpl.lot_id as lotId,
bpl.lot_name as lotName,
bui.unit_id as unitId,
bui.unit_name as unitName,
bai.back_time as backTime,
bagi.agreement_code as agreementCode,
tt.task_status as taskStatus,
tta.agreement_id as agreementId,
GROUP_CONCAT(bai.company_id) as companyId,
GROUP_CONCAT(DISTINCT bad.type_id) as typeId,
GROUP_CONCAT(mt2.type_name) AS typeName,
GROUP_CONCAT(bad.status) AS status
FROM
back_apply_info bai
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
LEFT JOIN tm_task tt on tt.task_id=bai.task_id
LEFT JOIN tm_task_agreement tta on tta.task_id=tt.task_id
LEFT JOIN bm_agreement_info bagi on bagi.agreement_id=tta.agreement_id
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bagi.project_id
LEFT JOIN bm_unit_info bui on bui.unit_id=bagi.unit_id
LEFT JOIN sys_user us on us.user_id=bai.create_by
LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
WHERE
1=1
<if test="keyWord != null and keyWord != ''">
and (bai.`code` like concat('%', #{keyWord}, '%') or
bai.back_person like concat('%', #{keyWord}, '%') or
bai.phone like concat('%', #{keyWord}, '%'))
</if>
<if test="unitId != null and unitId != ''">
and bui.unit_id = #{unitId}
</if>
<if test="lotId != null and lotId != ''">
and bpl.lot_id = #{lotId}
</if>
<if test="proId != null and proId != ''">
and bpl.lot_id = #{proId}
</if>
<if test="taskStatus != null and taskStatus != ''">
and tt.task_status = #{taskStatus}
</if>
<if test="agreementCode != null and agreementCode != ''">
and bagi.agreement_code like concat('%', #{agreementCode}, '%')
</if>
<if test="time != null and time != ''">
and bai.back_time =#{time}
</if>
GROUP BY bai.task_id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
ORDER BY bai.create_time desc
</select>
</mapper>