工器具台账
This commit is contained in:
parent
8043bc0c14
commit
f36d85dc1e
|
|
@ -48,6 +48,17 @@ public class ComplexQueryController extends BaseController {
|
|||
return AjaxResult.success(getDataTable(pageList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 工器具台账--APP
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "工器具台账查询")
|
||||
@GetMapping("/getToolsLedgerList")
|
||||
public AjaxResult getToolsLedgerList(RetainedEquipmentInfo bean) {
|
||||
return AjaxResult.success(complexQueryService.getToolsLedgerList(bean));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保有设备总量查询不带分页
|
||||
* @param bean
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 综合查询--保有设备总量查询
|
||||
|
|
@ -157,4 +158,8 @@ public class RetainedEquipmentInfo {
|
|||
@ApiModelProperty(value = "三级类型id")
|
||||
private Integer thirdTypeId;
|
||||
|
||||
private List<RetainedEquipmentInfo> modelList;
|
||||
|
||||
private boolean expanded = false;
|
||||
|
||||
}
|
||||
|
|
@ -145,4 +145,11 @@ public interface ComplexQueryMapper {
|
|||
* @return
|
||||
*/
|
||||
String getPartInfoList(MaTypeSelectInfo dto);
|
||||
|
||||
/**
|
||||
* 工器具台账查询
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<RetainedEquipmentInfo> getToolsLedgerList(RetainedEquipmentInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,4 +109,11 @@ public interface ComplexQueryService {
|
|||
* @return
|
||||
*/
|
||||
List<MaTypeSelectInfo> getMaTypeSelectList(MaTypeSelectInfo bean);
|
||||
|
||||
/**
|
||||
* 工器具台账查询
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<RetainedEquipmentInfo> getToolsLedgerList(RetainedEquipmentInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -511,4 +511,56 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RetainedEquipmentInfo> getToolsLedgerList(RetainedEquipmentInfo bean) {
|
||||
List<RetainedEquipmentInfo> list1 =new ArrayList<>();
|
||||
try {
|
||||
List<RetainedEquipmentInfo> list = complexQueryMapper.getToolsLedgerList(bean);
|
||||
if (list.size()>0){
|
||||
list1 = groupByThirdTypeId(list);
|
||||
}
|
||||
return list1;
|
||||
} catch (Exception e){
|
||||
log.error("获取设备台账列表失败,参数:{}", bean, e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public List<RetainedEquipmentInfo> groupByThirdTypeId(List<RetainedEquipmentInfo> dbList) {
|
||||
// 按thirdTypeId分组,同时保留typeName
|
||||
Map<Integer, List<RetainedEquipmentInfo>> groupedMap = dbList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
RetainedEquipmentInfo::getThirdTypeId,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
// 转换为目标格式
|
||||
List<RetainedEquipmentInfo> result = new ArrayList<>();
|
||||
|
||||
groupedMap.forEach((thirdTypeId, items) -> {
|
||||
if (!items.isEmpty()) {
|
||||
RetainedEquipmentInfo category = new RetainedEquipmentInfo();
|
||||
category.setThirdTypeId(thirdTypeId);
|
||||
category.setTypeName(items.get(0).getTypeName()); // 取第一个元素的typeName
|
||||
|
||||
List<RetainedEquipmentInfo> specs = items.stream()
|
||||
.map(item -> {
|
||||
RetainedEquipmentInfo spec = new RetainedEquipmentInfo();
|
||||
spec.setTypeModelName(item.getTypeModelName());
|
||||
spec.setUnit(item.getUnit());
|
||||
spec.setBuyPrice(item.getBuyPrice());
|
||||
spec.setStoreNum(item.getStoreNum());
|
||||
spec.setManageType(item.getManageType());
|
||||
return spec;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
category.setModelList(specs);
|
||||
result.add(category);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1129,5 +1129,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND rar.ma_id = #{maId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getToolsLedgerList" resultType="com.bonus.material.basic.domain.RetainedEquipmentInfo">
|
||||
SELECT
|
||||
mt.type_id AS typeId,
|
||||
mt4.type_name AS constructionType,
|
||||
mt4.type_id AS firstTypeId,
|
||||
mt3.type_name AS materialType,
|
||||
mt3.type_id AS secondTypeId,
|
||||
mt2.type_name AS typeName,
|
||||
mt2.type_id AS thirdTypeId,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unit,
|
||||
IFNULL(mt.lease_price, 0) AS buyPrice,
|
||||
CASE mt.manage_type
|
||||
WHEN 0 THEN
|
||||
IFNULL(subquery0.num, 0)
|
||||
ELSE
|
||||
IFNULL(mt.storage_num, 0)
|
||||
END AS storeNum,
|
||||
CASE mt.manage_type
|
||||
WHEN 0 THEN
|
||||
'编码'
|
||||
ELSE
|
||||
'数量'
|
||||
END manageType
|
||||
FROM ma_type mt
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt4.type_name AS constructionType,
|
||||
mt4.type_id AS firstTypeId,
|
||||
mt3.type_name AS materialType,
|
||||
mt3.type_id AS secondTypeId,
|
||||
mt2.type_name AS typeName,
|
||||
mt2.type_id AS thirdTypeId,
|
||||
mt.type_name AS typeModelName,
|
||||
count(mm.ma_id) AS num
|
||||
FROM ma_machine mm
|
||||
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.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 mm.ma_code is not null and mm.ma_status in (1)
|
||||
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
||||
|
||||
LEFT JOIN ma_type mt2 on mt2.type_id = mt.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 mt.`level` = 4
|
||||
and mt.del_flag = '0'
|
||||
and mt2.type_name is not null
|
||||
and mt2.type_id is not null
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue