退料申请表数据问题修改

This commit is contained in:
liang.chao 2024-02-23 17:26:16 +08:00
parent 7bbad756b1
commit baa645f36b
9 changed files with 161 additions and 58 deletions

View File

@ -254,7 +254,7 @@ public class BackApplyController extends BaseController {
* @param record 查询条件
* @return AjaxResult对象
*/
@Log(title = "退料审核列表", businessType = BusinessType.QUERY)
@Log(title = "获取退料审核列表-app", businessType = BusinessType.QUERY)
@PostMapping("examineList")
public AjaxResult examineList(@RequestBody BackApplyInfo record) {
try {

View File

@ -19,10 +19,10 @@ import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @description 退料申请--后台
* @author hay
* @date 2023/12/20 11:46
*/
* @author hay
* @description 退料申请--后台
* @date 2023/12/20 11:46
*/
@Api(tags = "退料申请")
@RestController
@RequestMapping("/backApply")
@ -33,18 +33,26 @@ public class BackApplyController extends BaseController {
/**
* 获取退料审核列表
*/
@ApiOperation(value = "获取退料审核列表")
@ApiOperation(value = "获取退料申请列表-web")
@GetMapping("/getBackApplyList")
public AjaxResult getBackApplyList(BackApplyInfo bean)
{
public AjaxResult getBackApplyList(BackApplyInfo bean) {
startPage();
List<BackApplyInfo> list = backApplyService.getBackApplyList(bean);
return AjaxResult.success(getDataTable(list));
}
@ApiOperation(value = "获取退料审核列表-web")
@GetMapping("/getBackAuditList")
public AjaxResult getBackAuditList(BackApplyInfo bean) {
startPage();
List<BackApplyInfo> list = backApplyService.getBackAuditList(bean);
return AjaxResult.success(getDataTable(list));
}
@ApiOperation(value = "在用设备类型树")
@PostMapping("/getUseTypeTree")
public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean){
public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) {
return backApplyService.getUseTypeTree(bean);
}
@ -53,8 +61,7 @@ public class BackApplyController extends BaseController {
*/
@ApiOperation(value = "获取在用物料列表")
@GetMapping("/getMaterialList")
public TableDataInfo getMaterialList(BackApplyInfo bean)
{
public TableDataInfo getMaterialList(BackApplyInfo bean) {
startPage();
List<BackApplyInfo> list = backApplyService.getMaterialList(bean);
return getDataTable(list);
@ -65,8 +72,7 @@ public class BackApplyController extends BaseController {
*/
@ApiOperation(value = "退料申请详情")
@GetMapping("/getView")
public TableDataInfo getView(BackApplyInfo bean)
{
public TableDataInfo getView(BackApplyInfo bean) {
startPage();
List<BackApplyInfo> list = backApplyService.getView(bean);
return getDataTable(list);
@ -77,8 +83,7 @@ public class BackApplyController extends BaseController {
*/
@ApiOperation(value = "退料单")
@GetMapping("/materialReturnNote")
public AjaxResult materialReturnNote(BackApplyInfo bean)
{
public AjaxResult materialReturnNote(BackApplyInfo bean) {
List<BackApplyInfo> list = backApplyService.getView(bean);
return success(list);
}
@ -88,8 +93,7 @@ public class BackApplyController extends BaseController {
*/
@ApiOperation(value = "退料申请详情修改")
@PostMapping("/setModify")
public AjaxResult setModify(@RequestBody BackApplyInfo bean)
{
public AjaxResult setModify(@RequestBody BackApplyInfo bean) {
return backApplyService.setModify(bean);
}
@ -98,16 +102,16 @@ public class BackApplyController extends BaseController {
*/
@ApiOperation(value = "退料申请删除")
@GetMapping("/del")
public AjaxResult del(BackApplyInfo bean)
{
public AjaxResult del(BackApplyInfo bean) {
return backApplyService.del(bean);
}
@Log(title = "退料申请提交", businessType = BusinessType.INSERT)
@PostMapping("/submitBackApply")
public AjaxResult submitBackApply(@RequestBody BackApplyInfo bean) {
boolean addLeaseTaskResult = false;
Long backApplyInfoId = 0L;
if (StringUtils.isNull(bean)) {
return AjaxResult.error("参数错误");
}
@ -137,10 +141,11 @@ public class BackApplyController extends BaseController {
Integer taskId = bean.getTaskId();
// 根据设备所属分公司拆分集合
List<List<BackApplyInfo>> backApplyInfoList = CollUtil.groupByField(bean.getBackApplyDetails(), "companyId");
// 对拆分后的集合进行each遍历
for (List<BackApplyInfo> leaseApplyDetailsList : backApplyInfoList) {
// 判断拆分后的集合内是否有数据
if (CollUtil.isNotEmpty(leaseApplyDetailsList)) {
// 判断拆分后的集合内是否有数据
if (CollUtil.isNotEmpty(backApplyInfoList)) {
// 对拆分后的集合进行each遍历
for (List<BackApplyInfo> leaseApplyDetailsList : backApplyInfoList) {
BackApplyInfo backApplyInfo1 = leaseApplyDetailsList.get(0);
// 对领料任务表的对象做数据处理
BackApplyInfo backApplyInfo = bean.getBackApplyInfo();
/* 创建领料单号*/
@ -148,17 +153,17 @@ public class BackApplyController extends BaseController {
/*设置任务ID*/
backApplyInfo.setTaskId(taskId);
/*设置设备所属分公司,用于交给哪家审核*/
backApplyInfo.setCompanyId(leaseApplyDetailsList.get(0).getCompanyId());
backApplyInfo.setCompanyId(backApplyInfo1.getCompanyId());
// 创建领料任务返回领料任务编号
boolean addLeaseTaskResult = backApplyService.insertBackApply(backApplyInfo) > 0;
addLeaseTaskResult = backApplyService.insertBackApply(backApplyInfo) > 0;
// 领料任务编号
backApplyInfoId = backApplyInfo.getId();
// 领料任务创建完成进行领料任务明细插入
if (addLeaseTaskResult) {
// 领料任务编号
Long backApplyInfoId = backApplyInfo.getId();
if (StringUtils.isNotNull(backApplyInfoId)) {
for (BackApplyInfo leaseApplyDetails : leaseApplyDetailsList) {
/* 设置领料任务ID*/
/* 设置领料任务ID*/
leaseApplyDetails.setId(backApplyInfoId);
// 插入领料任务明细
boolean addLeaseTaskDetailsResult = backApplyService.upload(leaseApplyDetails) > 0;
@ -166,57 +171,52 @@ public class BackApplyController extends BaseController {
return AjaxResult.error("退料任务创建成功,但退料任务明细插入失败");
}
}
return AjaxResult.success("退料申请成功,已完成");
} else {
return AjaxResult.error("退料任务编号为空");
}
} else {
return AjaxResult.error("创建退料任务失败,或退料明细为空");
}
}else {
return AjaxResult.error("创建任务失败,缺少数据");
}
} else {
return AjaxResult.error("创建任务失败,缺少数据");
}
} else {
return AjaxResult.error("创建任务失败");
}
}else {
} else {
return AjaxResult.error("创建任务失败");
}
} catch (Exception e) {
return AjaxResult.error("创建任务失败," + e.getCause().toString() + "," + e.getMessage());
}
return AjaxResult.error("任务创建失败");
return AjaxResult.success("退料任务创建成功");
}
@ApiOperation("退料审核-审核")
@Log(title = "退料审核列表-审核", businessType = BusinessType.UPDATE)
@PostMapping("/audit")
public AjaxResult audit(@RequestBody BackApplyInfo record)
{
public AjaxResult audit(@RequestBody BackApplyInfo record) {
return backApplyService.audit(record);
}
@ApiOperation("退料审核-驳回")
@Log(title = "退料审核列表-驳回", businessType = BusinessType.UPDATE)
@PostMapping("/refuse")
public AjaxResult refuse(@RequestBody BackApplyInfo record)
{
public AjaxResult refuse(@RequestBody BackApplyInfo record) {
return backApplyService.refuse(record);
}
/**
* 退料申请导出
*/
@ApiOperation("退料申请导出")
@Log(title = "退料申请导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BackApplyInfo bean)
{
public void export(HttpServletResponse response, BackApplyInfo bean) {
List<BackApplyInfo> list = backApplyService.exportList(bean);
ExcelUtil<BackApplyInfo> util = new ExcelUtil<BackApplyInfo>(BackApplyInfo.class);
util.exportExcel(response, list, "退料申请数据");

View File

@ -118,7 +118,7 @@ public class BackApplyInfo extends BaseEntity {
/** 数据所属组织 */
@ApiModelProperty(value = "数据所属组织")
private Long companyId;
private String companyId;
@ApiModelProperty(value = "关键字")
private String keyWord;

View File

@ -18,6 +18,7 @@ public class TypeTreeNode {
private long typeId;
private long parentId;
private int companyId;
private String num;

View File

@ -21,6 +21,8 @@ public interface BackApplyMapper {
*/
List<BackApplyInfo> getBackApplyList(BackApplyInfo bean);
List<BackApplyInfo> getBackApplyListByAdmin(BackApplyInfo bean);
/**
* 获取在用物料列表
* @param bean

View File

@ -12,11 +12,17 @@ import java.util.List;
*/
public interface BackApplyService {
/**
* 获取退料审核列表
* 获取退料申请列表
* @param bean
* @return
*/
List<BackApplyInfo> getBackApplyList(BackApplyInfo bean);
/**
* 获取退料审核列表
* @param bean
* @return
*/
List<BackApplyInfo> getBackAuditList(BackApplyInfo bean);
/**
* 获取在用物料列表
* @param bean

View File

@ -3,6 +3,7 @@ package com.bonus.sgzb.material.service.impl;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.material.domain.BackApplyInfo;
import com.bonus.sgzb.material.domain.TypeTreeNode;
import com.bonus.sgzb.material.mapper.BackApplyMapper;
@ -17,6 +18,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* @author hay
@ -30,6 +32,38 @@ public class BackApplyServiceImpl implements BackApplyService {
@Override
public List<BackApplyInfo> getBackApplyList(BackApplyInfo bean) {
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
if (roles.contains("admin")) {
//管理员可以看到所有退料申请
return backApplyMapper.getBackApplyListByAdmin(bean);
}
//个人只能看到自己的申请的退料
String username = SecurityUtils.getLoginUser().getUsername();
bean.setCreateBy(username);
return backApplyMapper.getBackApplyList(bean);
}
@Override
public List<BackApplyInfo> getBackAuditList(BackApplyInfo bean) {
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
if (roles.contains("admin")) {
//管理员可以看到所有退料申请
return backApplyMapper.getBackApplyListByAdmin(bean);
}
//机具分公司只能看到机具公司的退料
if (roles.contains("jjfgs")){
List<BackApplyInfo> backApplyListByAdmin = backApplyMapper.getBackApplyListByAdmin(bean);
for (BackApplyInfo backApplyInfo : backApplyListByAdmin) {
if (StringUtils.hasText(backApplyInfo.getCompanyId())){
}
}
return backApplyListByAdmin;
}
//调试分公司只能看到调试公司的退料
if (roles.contains("tsfgs")){
}
return backApplyMapper.getBackApplyList(bean);
}

View File

@ -326,7 +326,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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
tt.create_by = #{createBy}
<if test="keyWord != null and keyWord != ''">
and (bai.`code` like concat('%', #{keyWord}, '%') or
bai.back_person like concat('%', #{keyWord}, '%') or
@ -455,7 +455,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.type_name,
mt.`level`,
mt.unit_name,
mt4.num
mt4.num,
mt4.company_id
FROM
ma_type mt
LEFT JOIN (
@ -463,13 +464,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
subquery1.type_id AS typeId,
subquery1.parent_id ,
subquery1.typeName typeCode,
subquery1.out_num - COALESCE ( subquery2.audit_num, 0 ) AS num
subquery1.out_num - COALESCE ( subquery2.audit_num, 0 ) AS num,
subquery1.company_id
FROM
(-- 第一个查询作为子查询
SELECT
mt.type_id,
mt.parent_id,
mt.type_name AS typeName,
mt.company_id,
SUM( lod.out_num ) AS out_num
FROM
lease_apply_info lai
@ -489,6 +492,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.type_id,
mt.parent_id,
mt.type_name,
mt.company_id,
SUM( bad.audit_num ) AS audit_num
FROM
back_apply_info bai
@ -507,11 +511,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
HAVING num is not null
UNION ALL
SELECT ma_type.type_id, ma_type.parent_id,ma_type.type_name as typeCode, ma_type.`level`,ma_type.unit_name,0 as
num
num,ma_type.company_id
FROM ma_type
JOIN cte ON ma_type.type_id = cte.parent_id
)
SELECT type_id as typeId, parent_id as parentId,type_name as typeName,num,`level`,unit_name as unitNames
SELECT type_id as typeId, parent_id as parentId,type_name as typeName,num,`level`,unit_name as unitNames,company_id as companyId
FROM cte
WHERE
1=1
@ -527,7 +531,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</if>
GROUP BY type_id
ORDER BY type_id;
ORDER BY type_id
</select>
<select id="exportList" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
@ -578,5 +582,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
ORDER BY bai.task_id desc
</select>
<select id="getBackApplyListByAdmin" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
SELECT
bai.id,
bai.`code`,
bai.back_person as backPerson,
bai.phone,
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.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
ORDER BY bai.create_time desc
</select>
</mapper>

View File

@ -119,7 +119,7 @@
>保存</el-button
>
</el-col>
<el-col :span="1.5">
<!-- <el-button
type="warning"
@ -224,7 +224,7 @@
</el-table>
</div>
</template>
<script>
import { getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role";
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
@ -424,7 +424,7 @@ export default {
}
getInfo().then(res => {
this.companyId = res.user.companyId
this.createBy = res.user.createBy
this.createBy = res.user.userName
})
},
computed: {
@ -434,7 +434,7 @@ export default {
//
async GetUnitData() {
const params = {
id: this.queryParams.proId
id: this.queryParams.proId/* */
}
const res = await getUnitData(params)
this.unitList = res.data
@ -787,7 +787,7 @@ export default {
// row.num = 0
// }
},
///////
@ -813,7 +813,7 @@ export default {
const template = JSON.parse(JSON.stringify(this.leaseApplyDetailsItem))
template.createBy = this.createBy
template.typeId = node.data.typeId
template.companyId = this.companyId
template.companyId = node.data.companyId
// template.typeId = node.data.id
template.unitNames = node.data.unitNames
template.preNum = node.data.num
@ -824,4 +824,3 @@ export default {
}
};
</script>