问题修复
This commit is contained in:
parent
50157ab96a
commit
9721f824d7
|
|
@ -7,10 +7,12 @@ import com.bonus.aqgqj.basis.entity.vo.HomeVo;
|
|||
import com.bonus.aqgqj.basis.service.HomeService;
|
||||
import com.bonus.aqgqj.utils.DateTimeHelper;
|
||||
import com.bonus.aqgqj.utils.ListHelper;
|
||||
import com.bonus.aqgqj.utils.StringHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -104,16 +106,31 @@ public class HomeServiceImpl implements HomeService {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getCostRank(HomeVo vo) {
|
||||
Map<String, Object> map=new HashMap<>();
|
||||
try{
|
||||
List<HomeVo> list=dao.getCostRank(vo);
|
||||
map.put("data",list);
|
||||
map.put("code","200");
|
||||
}catch (Exception e){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
List<HomeVo> list = dao.getCostRank(vo);
|
||||
//将金额转换为万元
|
||||
for (HomeVo hvo : list) {
|
||||
if (StringHelper.isNotEmpty(hvo.getTotalCost())) {
|
||||
// 转换为 double 并除以 10000
|
||||
double value = Double.valueOf(hvo.getTotalCost()) / 10000;
|
||||
// 创建 DecimalFormat 实例,设置最多四位小数
|
||||
DecimalFormat df = new DecimalFormat("#.####");
|
||||
// 设置舍入模式为直接截断(可选,因为默认就是这样)
|
||||
df.setRoundingMode(java.math.RoundingMode.DOWN);
|
||||
// 格式化 double 值
|
||||
String formattedValue = df.format(value);
|
||||
hvo.setTotalCost(formattedValue);
|
||||
}
|
||||
}
|
||||
map.put("data", list);
|
||||
map.put("code", "200");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("code","400");
|
||||
map.put("code", "400");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,6 +231,9 @@ public class UserServiceImpl implements UserService {
|
|||
if (userDto.getRoleId().isEmpty()){
|
||||
userDto.setRoleId(null);
|
||||
}
|
||||
if (StringHelper.isEmpty(userDto.getTeamId())){
|
||||
userDto.setTeamId(null);
|
||||
}
|
||||
userDao.update(userDto);
|
||||
//saveUserRoles(userDto.getId(), userDto.getRoleIds());
|
||||
|
||||
|
|
|
|||
|
|
@ -46,30 +46,40 @@
|
|||
) aa group by teamName
|
||||
</select>
|
||||
<select id="getCostRank" parameterType="com.bonus.aqgqj.basis.entity.vo.HomeVo" resultType="com.bonus.aqgqj.basis.entity.vo.HomeVo">
|
||||
select aa.custom_name userName,aa.custom_user as contacts,aa.custom_phone as contactPhone,aa.orderNum,bb.totalCost,cc.cooperateDate from (
|
||||
select ec.id,ec.custom_name,ec.custom_user,ec.custom_phone,sum(te.dev_num) as orderNum from
|
||||
tb_custom ec
|
||||
left join tb_sample ts on ec.id=ts.custom_id
|
||||
left join tb_exper te on ts.id=te.sample_id
|
||||
left join tb_exper_items teis on te.id=teis.exper_id
|
||||
group by ec.custom_name,ec.custom_user,ec.custom_phone
|
||||
) aa
|
||||
left join (
|
||||
select ec.id,ec.custom_name,ec.custom_user,ec.custom_phone,sum(teis.amount) as totalCost from
|
||||
tb_custom ec
|
||||
left join tb_sample ts on ec.id=ts.custom_id
|
||||
left join tb_exper te on ts.id=te.sample_id
|
||||
left join tb_exper_items teis on te.id=teis.exper_id
|
||||
group by ec.custom_name,ec.custom_user,ec.custom_phone
|
||||
) bb on aa.id=bb.id
|
||||
left join (
|
||||
select ec.id,ec.custom_name,ec.custom_user,ec.custom_phone,max(ts.create_time) as cooperateDate from
|
||||
tb_custom ec
|
||||
left join tb_sample ts on ec.id=ts.custom_id
|
||||
left join tb_exper te on ts.id=te.sample_id
|
||||
left join tb_exper_items teis on te.id=teis.exper_id
|
||||
group by ec.custom_name,ec.custom_user,ec.custom_phone
|
||||
) cc on aa.id=cc.id
|
||||
where cooperateDate is not null order by totalCost desc
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT aa.id,
|
||||
aa.custom_name AS userName,
|
||||
aa.custom_user AS contacts,
|
||||
aa.custom_phone AS contactPhone,
|
||||
SUM(te.dev_num) AS orderNum,
|
||||
MAX(te.update_time) AS cooperateDate,
|
||||
SUM(te.dev_num * bb.amount) + SUM(IFNULL(ted.amount, 0)) AS totalCost
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
ec.id,
|
||||
ec.custom_name,
|
||||
ec.custom_user,
|
||||
ec.custom_phone
|
||||
FROM
|
||||
tb_custom ec
|
||||
WHERE
|
||||
ec.del_flag = 0
|
||||
AND ec.dept_id = 0
|
||||
) aa
|
||||
LEFT JOIN tb_exper te ON te.submit_unit = aa.id
|
||||
AND te.del_flag = 0
|
||||
LEFT JOIN tb_exper_dev ted ON ted.exper_id = te.id
|
||||
LEFT JOIN ( SELECT exper_id, SUM( IFNULL( amount, 0 ) ) AS amount FROM tb_exper_items GROUP BY exper_id ) bb ON bb.exper_id = te.id
|
||||
GROUP BY
|
||||
te.submit_unit
|
||||
) cc
|
||||
WHERE
|
||||
cc.cooperateDate IS NOT NULL
|
||||
ORDER BY
|
||||
cc.totalCost DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -231,9 +231,7 @@
|
|||
t.phone = #{phone},
|
||||
t.user_type = #{userType},
|
||||
t.login_type = #{loginType},
|
||||
<if test="teamId != null and teamId != ''">
|
||||
t.team_id = #{teamId},
|
||||
</if>
|
||||
t.team_id = #{teamId},
|
||||
t.state = #{state},
|
||||
t.update_time = now()
|
||||
where t.id = #{id}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ function iniTable(){
|
|||
cols: [[
|
||||
{field: 'num',type:'numbers',align:'center',title: '排名', width:'10%'}
|
||||
,{field: 'userName', title: '用户名称', width: '20%',align:"center"}
|
||||
,{field: 'totalCost', title: '总金额(元)', width: '15%',align:"center"}
|
||||
,{field: 'totalCost', title: '总金额(万元)', width: '15%',align:"center"}
|
||||
,{field: 'orderNum', title: '订单量', width: '12%',align:"center"}
|
||||
,{field: 'contacts', title: '联系人', width: '12%',align:"center"}
|
||||
,{field: 'contactPhone', title: '联系电话', width: '15%',align:"center"}
|
||||
|
|
|
|||
Loading…
Reference in New Issue