Commit d459a3be by wangchunyang

增加区县使用划分,样式调整

parent 62184577
...@@ -27,4 +27,6 @@ public class InboundImp { ...@@ -27,4 +27,6 @@ public class InboundImp {
private String production_date; private String production_date;
@ExcelProperty(value = "有效期至", index = 10) @ExcelProperty(value = "有效期至", index = 10)
private String expiry_date; private String expiry_date;
private String apply_dep_code;
} }
...@@ -50,10 +50,16 @@ public class KeyDmBorrowServiceImpl { ...@@ -50,10 +50,16 @@ public class KeyDmBorrowServiceImpl {
} }
} }
@ApiOperation(value = "领用申请列表", desc = "分页查询") @ApiOperation(value = "领用申请列表", desc = "分页查询")
public Page<Map<String, Object>> selectList(Map<String, Object> map) { public Page<Map<String, Object>> selectList(Page<Map<String, Object>> map) {
if (map == null) map = new HashMap<>(); if (map == null) map = new Page<>();
Map<String, Object> user = (Map<String, Object>) map.get("_user"); Map<String, Object> user = (Map<String, Object>) map.getParams().get("_user");
map.put("user", user); map.getParams().put("user", user);
// 获取应用机构代码
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
map.getParams().put("areaId", pos.get("area_id"));
map.getParams().put("parentIds", user.get("parent_ids")+","+pos.get("area_id"));
}
return commonService.findPage(namespace + "selectList", map); return commonService.findPage(namespace + "selectList", map);
} }
...@@ -62,18 +68,24 @@ public class KeyDmBorrowServiceImpl { ...@@ -62,18 +68,24 @@ public class KeyDmBorrowServiceImpl {
if (map == null) map = new HashMap<>(); if (map == null) map = new HashMap<>();
Map<String, Object> user = (Map<String, Object>) map.get("_user"); Map<String, Object> user = (Map<String, Object>) map.get("_user");
map.put("params", user); map.put("params", user);
// 获取应用机构代码
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
map.put("areaId", pos.get("area_id"));
map.put("parentIds", user.get("parent_ids")+","+pos.get("area_id"));
}
return commonService.findPage(namespace + "selectPendingList", map); return commonService.findPage(namespace + "selectPendingList", map);
} }
@ApiOperation(value = "历史申请列表", desc = "分页查询历史申请") @ApiOperation(value = "历史申请列表", desc = "分页查询历史申请")
public Page<Map<String, Object>> selectHistoryList(Map<String, Object> map) { public Page<Map<String, Object>> selectHistoryList(Page<Map<String, Object>> map) {
if (map == null) map = new HashMap<>(); if (map == null) map = new Page<>();
Map<String, Object> user = (Map<String, Object>) map.get("_user"); Map<String, Object> user = (Map<String, Object>) map.getParams().get("_user");
if (user != null) { if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user); Map<String, String> pos = DataScopeUtil.getPosition(user);
map.put("areaId", pos.get("area_id")); map.getParams().put("areaId", pos.get("area_id"));
map.put("parentId", user.get("parent_id")); map.getParams().put("parentId", user.get("parent_id"));
map.put("parentIds", user.get("parent_ids")+","+pos.get("area_id")); map.getParams().put("parentIds", user.get("parent_ids")+","+pos.get("area_id"));
} }
return commonService.findPage(namespace + "selectHistoryList", map); return commonService.findPage(namespace + "selectHistoryList", map);
} }
...@@ -116,7 +128,11 @@ public class KeyDmBorrowServiceImpl { ...@@ -116,7 +128,11 @@ public class KeyDmBorrowServiceImpl {
map.put("applicant_name", user.get("name")); map.put("applicant_name", user.get("name"));
map.put("department_id", user.get("company_id")); map.put("department_id", user.get("company_id"));
map.put("department_name", user.get("company_name")); map.put("department_name", user.get("company_name"));
// 设置应用机构代码
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
map.put("apply_dep_code", pos.get("area_id"));
}
map.put("approval_status", 0); map.put("approval_status", 0);
map.put("issue_status", 0); map.put("issue_status", 0);
...@@ -189,6 +205,14 @@ public class KeyDmBorrowServiceImpl { ...@@ -189,6 +205,14 @@ public class KeyDmBorrowServiceImpl {
throw new CustomException("审批失败:该申请无物料申领明细"); throw new CustomException("审批失败:该申请无物料申领明细");
} }
// 获取应用机构代码
Map<String, Object> user = (Map<String, Object>) map.get("_user");
String applyDepCode = null;
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
applyDepCode = pos.get("area_id");
}
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
// 遍历处理每个物料 // 遍历处理每个物料
for (Map<String, Object> details : detailsList) { for (Map<String, Object> details : detailsList) {
...@@ -197,6 +221,11 @@ public class KeyDmBorrowServiceImpl { ...@@ -197,6 +221,11 @@ public class KeyDmBorrowServiceImpl {
continue; continue;
} }
// 设置应用机构代码
if (applyDepCode != null) {
details.put("apply_dep_code", applyDepCode);
}
// 5. 查询物料库存信息 // 5. 查询物料库存信息
Map<String, Object> inventoryMap = commonService.getObject(namespace + "selectInventoryByMaterialId", details); Map<String, Object> inventoryMap = commonService.getObject(namespace + "selectInventoryByMaterialId", details);
if (inventoryMap == null) { if (inventoryMap == null) {
...@@ -242,6 +271,9 @@ public class KeyDmBorrowServiceImpl { ...@@ -242,6 +271,9 @@ public class KeyDmBorrowServiceImpl {
} }
// 插入日志:传当前物料的明细,而非整个申请的明细 // 插入日志:传当前物料的明细,而非整个申请的明细
detailItemsMap.put("op_type", 2); detailItemsMap.put("op_type", 2);
if (applyDepCode != null) {
detailItemsMap.put("apply_dep_code", applyDepCode);
}
commonService.insert(materialNamespace + "insertLog", detailItemsMap); commonService.insert(materialNamespace + "insertLog", detailItemsMap);
return sb.toString(); return sb.toString();
} }
......
...@@ -8,6 +8,7 @@ import com.scpyun.base.core.annotation.Api; ...@@ -8,6 +8,7 @@ import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation; import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException; import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService; import com.scpyun.base.db.service.CommonService;
import com.scpyun.platform.jilinsscgsdp.utils.DataScopeUtil;
import com.scpyun.platform.jilinsscgsdp.utils.InboundFileListener; import com.scpyun.platform.jilinsscgsdp.utils.InboundFileListener;
import com.scpyun.platform.jilinsscgsdp.utils.MaterialFileListener; import com.scpyun.platform.jilinsscgsdp.utils.MaterialFileListener;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -45,7 +46,7 @@ public class KeyDmInboundServiceImpl { ...@@ -45,7 +46,7 @@ public class KeyDmInboundServiceImpl {
private static final Logger log = LoggerFactory.getLogger(KeyDmInboundServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(KeyDmInboundServiceImpl.class);
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmInbound."; private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmInbound.";
private final String detailNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmInboundDetail."; private final String detailNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmInbound.";
private final String materialNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog."; private final String materialNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog.";
private final String borrowNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow."; private final String borrowNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow.";
private final String userNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmUser."; private final String userNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmUser.";
...@@ -67,8 +68,15 @@ public class KeyDmInboundServiceImpl { ...@@ -67,8 +68,15 @@ public class KeyDmInboundServiceImpl {
} }
@ApiOperation(value = "入库记录列表", desc = "分页查询") @ApiOperation(value = "入库记录列表", desc = "分页查询")
public Page<Map<String, Object>> selectList(Map<String, Object> map) { public Page<Map<String, Object>> selectList(Page<Map<String, Object>> map) {
if (map == null) map = new HashMap<>(); if (map == null) map = new Page<>();
// 获取应用机构代码
Map<String, Object> user = (Map<String, Object>) map.getParams().get("_user");
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
map.getParams().put("areaId", pos.get("area_id"));
map.getParams().put("parentIds", user.get("parent_ids")+","+pos.get("area_id"));
}
return commonService.findPage(namespace + "selectList", map); return commonService.findPage(namespace + "selectList", map);
} }
...@@ -103,6 +111,12 @@ public class KeyDmInboundServiceImpl { ...@@ -103,6 +111,12 @@ public class KeyDmInboundServiceImpl {
System.out.println(map); System.out.println(map);
map.put("id", UUID.randomUUID().toString()); map.put("id", UUID.randomUUID().toString());
map.put("order_no",0); map.put("order_no",0);
// 设置应用机构代码
Map<String, Object> user = (Map<String, Object>) map.get("_user");
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
map.put("apply_dep_code", pos.get("area_id"));
}
map.put("inbound_status",0); map.put("inbound_status",0);
if (commonService.insert(namespace + "insert", map) != 1) throw new CustomException("保存失败"); if (commonService.insert(namespace + "insert", map) != 1) throw new CustomException("保存失败");
...@@ -158,8 +172,15 @@ public class KeyDmInboundServiceImpl { ...@@ -158,8 +172,15 @@ public class KeyDmInboundServiceImpl {
} }
@ApiOperation(value = "待归还列表(来自申领)", desc = "查询待归还记录") @ApiOperation(value = "待归还列表(来自申领)", desc = "查询待归还记录")
public Page<Map<String, Object>> selectPendingReturnList(Map<String, Object> map) { public Page<Map<String, Object>> selectPendingReturnList(Page<Map<String, Object>> map) {
if (map == null) map = new HashMap<>(); if (map == null) map = new Page<>();
// 获取应用机构代码
Map<String, Object> user = (Map<String, Object>) map.getParams().get("_user");
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
map.getParams().put("areaId", pos.get("area_id"));
map.getParams().put("parentIds", user.get("parent_ids")+","+pos.get("area_id"));
}
return commonService.findPage(namespace + "selectPendingReturnList", map); return commonService.findPage(namespace + "selectPendingReturnList", map);
} }
...@@ -223,6 +244,13 @@ public class KeyDmInboundServiceImpl { ...@@ -223,6 +244,13 @@ public class KeyDmInboundServiceImpl {
String inboundId = UUID.randomUUID().toString(); String inboundId = UUID.randomUUID().toString();
returnData.put(FIELD_INBOUND_ID, inboundId); returnData.put(FIELD_INBOUND_ID, inboundId);
// 设置应用机构代码
Map<String, Object> user = (Map<String, Object>) returnData.get("_user");
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
returnData.put("apply_dep_code", pos.get("area_id"));
}
// 插入入库主表 // 插入入库主表
commonService.insert(namespace + "insertInboundByReturn", returnData); commonService.insert(namespace + "insertInboundByReturn", returnData);
log.debug("插入入库主表成功,入库单ID:{}", inboundId); log.debug("插入入库主表成功,入库单ID:{}", inboundId);
...@@ -251,6 +279,13 @@ public class KeyDmInboundServiceImpl { ...@@ -251,6 +279,13 @@ public class KeyDmInboundServiceImpl {
detail.put("op_type", OP_TYPE_RETURN); detail.put("op_type", OP_TYPE_RETURN);
detail.put("_user", returnData.get("_user")); detail.put("_user", returnData.get("_user"));
// 设置应用机构代码
Map<String, Object> user = (Map<String, Object>) detail.get("_user");
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
detail.put("apply_dep_code", pos.get("area_id"));
}
// 更新申领明细归还数量 // 更新申领明细归还数量
commonService.insert(namespace + "updateBorrowDetailReturnedQuantity", detail); commonService.insert(namespace + "updateBorrowDetailReturnedQuantity", detail);
// 更新库存(借出数量扣减) // 更新库存(借出数量扣减)
...@@ -276,8 +311,15 @@ public class KeyDmInboundServiceImpl { ...@@ -276,8 +311,15 @@ public class KeyDmInboundServiceImpl {
} }
@ApiOperation(value = "库存查询", desc = "实时库存") @ApiOperation(value = "库存查询", desc = "实时库存")
public Page<Map<String, Object>> selectInventoryList(Map<String, Object> map) { public Page<Map<String, Object>> selectInventoryList(Page<Map<String, Object>> map) {
if (map == null) map = new HashMap<>(); if (map == null) map = new Page<>();
// 获取应用机构代码
Map<String, Object> user = (Map<String, Object>) map.getParams().get("_user");
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
map.getParams().put("areaId", pos.get("area_id"));
map.getParams().put("parentIds", user.get("parent_ids")+","+pos.get("area_id"));
}
return commonService.findPage(namespace + "selectInventoryList", map); return commonService.findPage(namespace + "selectInventoryList", map);
} }
......
...@@ -33,12 +33,17 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> { ...@@ -33,12 +33,17 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
private Map<String, List<InboundImp>> inboundGroupMap = new HashMap<>(); private Map<String, List<InboundImp>> inboundGroupMap = new HashMap<>();
private Map<String, Object> user = null; private Map<String, Object> user = null;
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
private String areaId;
public InboundFileListener(CommonService commonService, String namespace, Map<String,Object> param) { public InboundFileListener(CommonService commonService, String namespace, Map<String,Object> param) {
this.commonService = commonService; this.commonService = commonService;
this.namespace = namespace; this.namespace = namespace;
this.param = param; this.param = param;
user = (Map<String, Object>) param.get("_user"); user = (Map<String, Object>) param.get("_user");
if (user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(user);
areaId = pos.get("area_id");
}
// 初始化日期格式 // 初始化日期格式
dateFormat.setLenient(false); dateFormat.setLenient(false);
// 初始化物料映射 // 初始化物料映射
...@@ -70,6 +75,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> { ...@@ -70,6 +75,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
try { try {
// 数据校验 // 数据校验
if (isValidInbound(data)) { if (isValidInbound(data)) {
data.setApply_dep_code(areaId);
cached.add(data); cached.add(data);
// 按入库单号和批次号分组 // 按入库单号和批次号分组
String groupKey = getGroupKey(data); String groupKey = getGroupKey(data);
...@@ -311,6 +317,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> { ...@@ -311,6 +317,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
Map<String, Object> batchParam = new HashMap<>(); Map<String, Object> batchParam = new HashMap<>();
batchParam.put("list", updateList); batchParam.put("list", updateList);
batchParam.put("_user", user); batchParam.put("_user", user);
batchParam.put("areaId", areaId);
commonService.update(namespace + "batchUpdateMaterialStock", batchParam); commonService.update(namespace + "batchUpdateMaterialStock", batchParam);
} }
...@@ -332,6 +339,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> { ...@@ -332,6 +339,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
master.put("batch_no", data.getBatch_no()); master.put("batch_no", data.getBatch_no());
master.put("inbound_type", 1); master.put("inbound_type", 1);
master.put("inbound_status", 1); // 1-已入库 master.put("inbound_status", 1); // 1-已入库
master.put("apply_dep_code", data.getApply_dep_code()); //所属部门
// 处理入库日期 // 处理入库日期
Date inboundDate = null; Date inboundDate = null;
...@@ -377,6 +385,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> { ...@@ -377,6 +385,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
detail.put("id", UUIDUtil.getUUID()); detail.put("id", UUIDUtil.getUUID());
detail.put("inbound_id", inboundId); detail.put("inbound_id", inboundId);
detail.put("material_id", materialTempMap.get("id")); detail.put("material_id", materialTempMap.get("id"));
detail.put("apply_dep_code", data.getApply_dep_code()); //所属,用于库存保存传递参数
// 物料名称优先使用Excel中的,否则使用系统已有的 // 物料名称优先使用Excel中的,否则使用系统已有的
String materialName = StringUtils.isNotEmpty(data.getMaterial_name()) ? String materialName = StringUtils.isNotEmpty(data.getMaterial_name()) ?
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
<where> <where>
is_used = 1 is_used = 1
and applicant_id = #{params.user.id} and applicant_id = #{params.user.id}
<if test="params.areaId != null and params.areaId != ''">
AND apply_dep_code = #{params.areaId}
</if>
<if test="params.params.applicant_name != null and params.params.applicant_name != ''"> <if test="params.params.applicant_name != null and params.params.applicant_name != ''">
AND applicant_name LIKE CONCAT('%', #{params.params.applicant_name}, '%') AND applicant_name LIKE CONCAT('%', #{params.params.applicant_name}, '%')
</if> </if>
...@@ -32,6 +35,9 @@ ...@@ -32,6 +35,9 @@
is_used = 1 is_used = 1
AND approval_status = 1 AND approval_status = 1
and approver_id = #{params.params.id} and approver_id = #{params.params.id}
<if test="params.areaId != null and params.areaId != ''">
AND apply_dep_code = #{params.areaId}
</if>
</where> </where>
ORDER BY submit_time DESC ORDER BY submit_time DESC
</select> </select>
...@@ -41,7 +47,7 @@ ...@@ -41,7 +47,7 @@
left join jl_key_dm_user u on ba.applicant_id=u.id left join jl_key_dm_user u on ba.applicant_id=u.id
left join sys_office so on u.office_id=so.id left join sys_office so on u.office_id=so.id
<where> <where>
ba.is_used = 1 and so.area_id = #{params.areaId} ba.is_used = 1 and so.area_id = #{params.areaId} and ba.apply_dep_code = #{params.areaId}
<if test="params.params.applicant_name != null and params.params.applicant_name != ''"> <if test="params.params.applicant_name != null and params.params.applicant_name != ''">
AND ba.applicant_name LIKE CONCAT('%', #{params.params.applicant_name}, '%') AND ba.applicant_name LIKE CONCAT('%', #{params.params.applicant_name}, '%')
</if> </if>
...@@ -68,10 +74,10 @@ ...@@ -68,10 +74,10 @@
<insert id="insert" parameterType="map"> <insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_borrow_application( INSERT INTO jl_key_dm_borrow_application(
id,application_no,applicant_id,applicant_name,department_id,department_name,borrow_purpose,expected_return_date,approver_id,approver_name, id,application_no,applicant_id,applicant_name,department_id,department_name,borrow_purpose,expected_return_date,approver_id,approver_name,
approval_status,issue_status,is_used,create_by,create_time,order_no approval_status,issue_status,is_used,create_by,create_time,order_no,apply_dep_code
) VALUES ( ) VALUES (
#{id},CONCAT('borrow', REPLACE(UUID(),'-','')),#{applicant_id},#{applicant_name},#{department_id},#{department_name},#{borrow_purpose},#{expected_return_date},#{approver_id},#{approver_name}, #{id},CONCAT('borrow', REPLACE(UUID(),'-','')),#{applicant_id},#{applicant_name},#{department_id},#{department_name},#{borrow_purpose},#{expected_return_date},#{approver_id},#{approver_name},
#{approval_status},#{issue_status},1,#{_user.id},NOW(),#{order_no} #{approval_status},#{issue_status},1,#{_user.id},NOW(),#{order_no},#{apply_dep_code}
) )
</insert> </insert>
...@@ -189,8 +195,8 @@ ...@@ -189,8 +195,8 @@
<!-- 生成出库记录与明细(批量由 mapper 内部实现) --> <!-- 生成出库记录与明细(批量由 mapper 内部实现) -->
<insert id="insertOutboundByApplication" parameterType="map"> <insert id="insertOutboundByApplication" parameterType="map">
<!-- mapper implementation should insert outbound record and details based on application id --> <!-- mapper implementation should insert outbound record and details based on application id -->
INSERT INTO jl_key_dm_outbound_record(id,outbound_no,outbound_type,outbound_date,receiver_id,receiver_name,receiver_department_id,receiver_department_name,outbound_status,remark,is_used,create_by,create_time) INSERT INTO jl_key_dm_outbound_record(id,outbound_no,outbound_type,outbound_date,receiver_id,receiver_name,receiver_department_id,receiver_department_name,outbound_status,remark,is_used,create_by,create_time,apply_dep_code)
SELECT UUID(), CONCAT('OUT', REPLACE(UUID(),'-','')) , 2, NOW(), applicant_id, applicant_name, department_id, department_name, 1, borrow_purpose, 1, #{_user.id}, NOW() SELECT UUID(), CONCAT('OUT', REPLACE(UUID(),'-','')) , 2, NOW(), applicant_id, applicant_name, department_id, department_name, 1, borrow_purpose, 1, #{_user.id}, NOW(), apply_dep_code
FROM jl_key_dm_borrow_application WHERE id = #{id} FROM jl_key_dm_borrow_application WHERE id = #{id}
</insert> </insert>
...@@ -210,6 +216,9 @@ ...@@ -210,6 +216,9 @@
left join jl_key_dm_material as m left join jl_key_dm_material as m
on m.id = i.material_id on m.id = i.material_id
where material_id = #{material_id} where material_id = #{material_id}
<if test="apply_dep_code != null and apply_dep_code != ''">
AND i.apply_dep_code = #{apply_dep_code}
</if>
</select> </select>
...@@ -220,6 +229,9 @@ ...@@ -220,6 +229,9 @@
update jl_key_dm_inventory update jl_key_dm_inventory
set total_quantity = total_quantity - #{apply_quantity} set total_quantity = total_quantity - #{apply_quantity}
where material_id = #{material_id} where material_id = #{material_id}
<if test="apply_dep_code != null and apply_dep_code != ''">
AND apply_dep_code = #{apply_dep_code}
</if>
</update> </update>
<!-- 更新库存:根据申请明细扣减可用库存(mapper 内部实现以事务执行) --> <!-- 更新库存:根据申请明细扣减可用库存(mapper 内部实现以事务执行) -->
...@@ -229,6 +241,9 @@ ...@@ -229,6 +241,9 @@
update jl_key_dm_inventory update jl_key_dm_inventory
set borrowed_quantity = borrowed_quantity + #{apply_quantity} set borrowed_quantity = borrowed_quantity + #{apply_quantity}
where material_id = #{material_id} where material_id = #{material_id}
<if test="apply_dep_code != null and apply_dep_code != ''">
AND apply_dep_code = #{apply_dep_code}
</if>
</update> </update>
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
SELECT * FROM jl_key_dm_inbound_record SELECT * FROM jl_key_dm_inbound_record
<where> <where>
AND is_used = 1 AND is_used = 1
<if test="params.areaId != null and params.areaId != ''">
AND apply_dep_code = #{params.areaId}
</if>
<if test="params.params.inbound_no != null"> <if test="params.params.inbound_no != null">
AND inbound_no LIKE CONCAT('%', #{params.params.inbound_no}, '%') AND inbound_no LIKE CONCAT('%', #{params.params.inbound_no}, '%')
</if> </if>
...@@ -34,9 +37,9 @@ ...@@ -34,9 +37,9 @@
<insert id="insert" parameterType="map"> <insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_inbound_record( INSERT INTO jl_key_dm_inbound_record(
id,inbound_no,batch_no,inbound_date,inbound_type,storage_location,inbound_status,remark,is_used,create_by,create_time,order_no id,inbound_no,batch_no,inbound_date,inbound_type,storage_location,inbound_status,remark,is_used,create_by,create_time,order_no,apply_dep_code
) VALUES ( ) VALUES (
#{id},#{inbound_no},#{batch_no},#{inbound_date},#{inbound_type},#{storage_location},#{inbound_status},#{remark},1,#{_user.id},NOW(),#{order_no} #{id},#{inbound_no},#{batch_no},#{inbound_date},#{inbound_type},#{storage_location},#{inbound_status},#{remark},1,#{_user.id},NOW(),#{order_no},#{apply_dep_code}
) )
</insert> </insert>
...@@ -59,6 +62,9 @@ ...@@ -59,6 +62,9 @@
SELECT * FROM jl_key_dm_inventory SELECT * FROM jl_key_dm_inventory
<where> <where>
AND is_used = 1 AND is_used = 1
<if test="params.reaId != null and params.areaId != ''">
AND apply_dep_code = #{params.areaId}
</if>
<if test="params.params.material_name != null"> <if test="params.params.material_name != null">
AND material_name LIKE CONCAT('%', #{params.params.material_name}, '%') AND material_name LIKE CONCAT('%', #{params.params.material_name}, '%')
</if> </if>
...@@ -72,8 +78,8 @@ ...@@ -72,8 +78,8 @@
<!-- 入库主表添加归还入库单 --> <!-- 入库主表添加归还入库单 -->
<insert id="insertInboundByReturn" parameterType="map"> <insert id="insertInboundByReturn" parameterType="map">
INSERT INTO jl_key_dm_inbound_record(id,inbound_no,batch_no,inbound_date,inbound_type,storage_location,inbound_status,remark,is_used,create_by,create_time) INSERT INTO jl_key_dm_inbound_record(id,inbound_no,batch_no,inbound_date,inbound_type,storage_location,inbound_status,remark,is_used,create_by,create_time,apply_dep_code)
SELECT #{inbound_id}, CONCAT('INR', REPLACE(UUID(),'-','')), '', NOW(), 2, '', 1, '归还入库', 1, #{_user.id}, NOW() SELECT #{inbound_id}, CONCAT('INR', REPLACE(UUID(),'-','')), '', NOW(), 2, '', 1, '归还入库', 1, #{_user.id}, NOW(), #{apply_dep_code}
FROM jl_key_dm_borrow_application WHERE id = #{id} FROM jl_key_dm_borrow_application WHERE id = #{id}
</insert> </insert>
<!-- 入库明细添加 --> <!-- 入库明细添加 -->
...@@ -94,6 +100,9 @@ ...@@ -94,6 +100,9 @@
set borrowed_quantity = borrowed_quantity - #{apply_quantity} set borrowed_quantity = borrowed_quantity - #{apply_quantity}
,damaged_quantity = damaged_quantity + #{damaged_quantity} ,damaged_quantity = damaged_quantity + #{damaged_quantity}
where material_id = #{material_id} where material_id = #{material_id}
<if test="apply_dep_code != null and apply_dep_code != ''">
AND apply_dep_code = #{apply_dep_code}
</if>
</update> </update>
<!-- update inventory by inbound (placeholder) --> <!-- update inventory by inbound (placeholder) -->
...@@ -114,7 +123,8 @@ ...@@ -114,7 +123,8 @@
create_time, create_time,
update_by, update_by,
update_time, update_time,
order_no order_no,
apply_dep_code
) )
VALUES VALUES
<foreach collection="details" item="item" separator=","> <foreach collection="details" item="item" separator=",">
...@@ -132,7 +142,8 @@ ...@@ -132,7 +142,8 @@
NOW(), NOW(),
#{_user.id}, #{_user.id},
NOW(), NOW(),
#{item.order_no} #{item.order_no},
#{apply_dep_code}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
...@@ -153,7 +164,11 @@ ...@@ -153,7 +164,11 @@
FROM jl_key_dm_material_log as ml FROM jl_key_dm_material_log as ml
left join jl_key_dm_material as m left join jl_key_dm_material as m
on m.id = ml.material_id on m.id = ml.material_id
WHERE ml.relation_id = #{id} AND ml.is_used = 1 ORDER BY ml.create_time ASC WHERE ml.relation_id = #{id} AND ml.is_used = 1
<if test="apply_dep_code != null and apply_dep_code != ''">
AND ml.apply_dep_code = #{apply_dep_code}
</if>
ORDER BY ml.create_time ASC
</select> </select>
<select id="selectPendingReturnList" parameterType="map" resultType="map"> <select id="selectPendingReturnList" parameterType="map" resultType="map">
...@@ -166,6 +181,9 @@ ...@@ -166,6 +181,9 @@
<where> <where>
m.can_borrow = 1 and ba.issue_status = 1 m.can_borrow = 1 and ba.issue_status = 1
and bad.returned_quantity + bad.damaged_quantity != bad.apply_quantity and bad.returned_quantity + bad.damaged_quantity != bad.apply_quantity
<if test="params.areaId != null and params.areaId != ''">
AND ba.apply_dep_code = #{params.areaId}
</if>
<if test="params.params.applicant_name != null and params.params.applicant_name != ''"> <if test="params.params.applicant_name != null and params.params.applicant_name != ''">
and applicant_name like concat('%',#{params.params.applicant_name},'%') and applicant_name like concat('%',#{params.params.applicant_name},'%')
</if> </if>
...@@ -205,7 +223,8 @@ ...@@ -205,7 +223,8 @@
storage_location, storage_location,
remark, remark,
create_by, create_by,
create_time create_time,
apply_dep_code
) VALUES ) VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (
...@@ -219,7 +238,8 @@ ...@@ -219,7 +238,8 @@
#{item.storage_location}, #{item.storage_location},
#{item.remark}, #{item.remark},
#{item.create_by}, #{item.create_by},
#{item.create_time} #{item.create_time},
#{item.apply_dep_code}
) )
</foreach> </foreach>
</insert> </insert>
...@@ -264,7 +284,8 @@ ...@@ -264,7 +284,8 @@
ELSE 0 ELSE 0
END, END,
update_time = NOW() update_time = NOW()
WHERE id IN WHERE apply_dep_code = #{areaId}
AND id IN
<foreach collection="list" item="item" open="(" separator="," close=")"> <foreach collection="list" item="item" open="(" separator="," close=")">
#{item.material_id} #{item.material_id}
</foreach> </foreach>
...@@ -323,6 +344,32 @@ ...@@ -323,6 +344,32 @@
#{create_time} #{create_time}
) )
</insert> </insert>
<!-- details-->
<insert id="insertDetail" parameterType="map">
INSERT INTO jl_key_dm_inbound_detail(
id,inbound_id,material_id,inbound_type,inbound_quantity,unit_price,total_amount,production_date,expiry_date,is_used,create_by,create_time
) VALUES (
#{id},#{inbound_id},#{material_id},#{inbound_type},#{inbound_quantity},#{unit_price},#{total_amount},#{production_date},#{expiry_date},1,#{_user.id},NOW()
)
</insert>
<select id="selectDetailsByInboundId" parameterType="map" resultType="map">
SELECT i.*,
m.material_code, m.material_name, m.category_id
FROM jl_key_dm_inbound_detail as i
left join jl_key_dm_material as m
on i.material_id = m.id
WHERE i.inbound_id = #{id} AND i.is_used = 1 ORDER BY i.create_time ASC
</select>
<!-- <delete id="deleteDetailsByInboundId" parameterType="map">-->
<!-- DELETE FROM jl_key_dm_inbound_detail WHERE inbound_id = #{id}-->
<!-- </delete>-->
<update id="deleteDetailsByInboundId" parameterType="map">
UPDATE jl_key_dm_inbound_detail SET is_used = 0, update_by = #{_user.id}, update_time = NOW() WHERE inbound_id = #{id}
</update>
</mapper> </mapper>
...@@ -295,10 +295,10 @@ ...@@ -295,10 +295,10 @@
AND la.status = 9 AND la.status = 9
AND so.area_id = #{area_id} AND so.area_id = #{area_id}
<if test="start != null and start != ''"> <if test="start != null and start != ''">
AND la.end_time >= #{start} AND la.end_time &gt;= #{start}
</if> </if>
<if test="end != null and end != ''"> <if test="end != null and end != ''">
And la.start_time &lt; #{end} And la.start_time &lt;= #{end}
</if> </if>
</where> </where>
GROUP BY la.user_id, la.user_name, la.department_id, la.department_name GROUP BY la.user_id, la.user_name, la.department_id, la.department_name
......
...@@ -738,7 +738,8 @@ ...@@ -738,7 +738,8 @@
LEFT JOIN sys_office so on so.id = ba.department_id LEFT JOIN sys_office so on so.id = ba.department_id
<where> <where>
AND ba.is_used=1 and ad.is_used=1 and ba.approval_status = 9 AND ba.is_used=1 and ad.is_used=1 and ba.approval_status = 9
AND so.area_id = #{areaId} <!-- AND so.area_id = #{areaId}-->
AND ba.apply_dep_code = #{areaId}
<if test="start != null and start != ''"> <if test="start != null and start != ''">
AND ba.create_time &gt;= #{start} AND ba.create_time &gt;= #{start}
</if> </if>
...@@ -826,7 +827,7 @@ ...@@ -826,7 +827,7 @@
SELECT b.applicant_id AS uid, b.applicant_name AS uname, 0, 0, 1, 0, 0, 0 SELECT b.applicant_id AS uid, b.applicant_name AS uname, 0, 0, 1, 0, 0, 0
FROM jl_key_dm_borrow_application b FROM jl_key_dm_borrow_application b
<where> <where>
AND b.is_used = 1 AND b.approval_status != 0 AND b.is_used = 1 AND b.approval_status != 0 AND b.apply_dep_code = #{areaId}
<if test="start != null and start != ''"> <if test="start != null and start != ''">
AND b.submit_time &gt;= #{start} AND b.submit_time &gt;= #{start}
</if> </if>
...@@ -838,7 +839,7 @@ ...@@ -838,7 +839,7 @@
SELECT ba.approver_id AS uid, u.name AS uname, 0, 0, 0, 1, 0, 0 SELECT ba.approver_id AS uid, u.name AS uname, 0, 0, 0, 1, 0, 0
FROM jl_key_dm_borrow_application ba left join jl_key_dm_user u on ba.approver_id = u.id FROM jl_key_dm_borrow_application ba left join jl_key_dm_user u on ba.approver_id = u.id
<where> <where>
AND ba.is_used = 1 AND (ba.approval_status = 9 OR ba.approval_status = -1) AND ba.is_used = 1 AND (ba.approval_status = 9 OR ba.approval_status = -1) AND ba.apply_dep_code = #{areaId}
<if test="start != null and start != ''"> <if test="start != null and start != ''">
AND ba.approval_time &gt;= #{start} AND ba.approval_time &gt;= #{start}
</if> </if>
...@@ -850,7 +851,7 @@ ...@@ -850,7 +851,7 @@
SELECT ir.create_by AS uid, du.`name` AS uname, 0, 0, 0, 0, 1, 0 SELECT ir.create_by AS uid, du.`name` AS uname, 0, 0, 0, 0, 1, 0
FROM jl_key_dm_inbound_record ir LEFT JOIN jl_key_dm_user du on ir.create_by = du.id FROM jl_key_dm_inbound_record ir LEFT JOIN jl_key_dm_user du on ir.create_by = du.id
<where> <where>
AND ir.is_used = 1 AND ir.is_used = 1 AND ir.apply_dep_code = #{areaId}
<if test="start != null and start != ''"> <if test="start != null and start != ''">
AND ir.create_time &gt;= #{start} AND ir.create_time &gt;= #{start}
</if> </if>
...@@ -859,7 +860,7 @@ ...@@ -859,7 +860,7 @@
</if> </if>
</where> </where>
) t LEFT JOIN jl_key_dm_user u on t.uid=u.id LEFT JOIN sys_office o on u.office_id=o.id ) t LEFT JOIN jl_key_dm_user u on t.uid=u.id LEFT JOIN sys_office o on u.office_id=o.id
WHERE o.area_id = #{areaId} <!-- WHERE o.area_id = #{areaId}-->
GROUP BY t.uid, t.uname, o.name, o.grade, o.sort GROUP BY t.uid, t.uname, o.name, o.grade, o.sort
ORDER BY o.grade, o.sort, leave_applications DESC, borrow_applications DESC ORDER BY o.grade, o.sort, leave_applications DESC, borrow_applications DESC
</select> </select>
......
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
LEFT JOIN sys_office o ON o.id = u.office_id LEFT JOIN sys_office o ON o.id = u.office_id
<where> <where>
AND u.is_used = 1 AND u.is_used = 1
AND (o.parent_ids LIKE CONCAT(#{params.parentIds}, '%') OR u.office_id = #{params._user.company_id}) AND o.area_id = #{params.areaId}
<!-- AND (o.parent_ids LIKE CONCAT(#{params.parentIds}, '%') OR u.office_id = #{params._user.company_id})-->
<if test="params.name != null and params.name != ''"> <if test="params.name != null and params.name != ''">
AND u.name LIKE CONCAT('%', #{params.name}, '%') AND u.name LIKE CONCAT('%', #{params.name}, '%')
</if> </if>
</where> </where>
ORDER BY o.grade,o.sort,u.order_no ASC, u.create_time DESC ORDER BY o.grade,o.sort,u.order_no ASC, u.gh
</select> </select>
<select id="selectUserLeaderById" parameterType="page" resultType="map"> <select id="selectUserLeaderById" parameterType="page" resultType="map">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论